This commit is contained in:
2020-11-10 18:04:42 +08:00
parent 6cb8172b56
commit 2e04f5a9b7
+26 -9
View File
@@ -9,13 +9,13 @@ use HttpServer\Http\HttpParams;
use HttpServer\Http\Request; use HttpServer\Http\Request;
use Exception; use Exception;
use Snowflake\Abstracts\BaseGoto; use Snowflake\Abstracts\BaseGoto;
use Snowflake\Exception\ComponentException;
use Snowflake\Snowflake; use Snowflake\Snowflake;
/** /**
* Class WebController * Class WebController
* @package Snowflake\Snowflake\Web * @package Snowflake\Snowflake\Web
* @property BaseGoto $goto * @property BaseGoto $goto
* @property \Snowflake\Application $app
*/ */
class Controller extends Application class Controller extends Application
{ {
@@ -32,16 +32,12 @@ class Controller extends Application
public Request $request; public Request $request;
public BaseGoto $goto; /**
* Controller constructor.
* @param array $config
public $app; */
public function __construct($config = []) public function __construct($config = [])
{ {
$this->app = Snowflake::app();
$this->goto = $this->app->goto;
parent::__construct($config); parent::__construct($config);
} }
@@ -106,4 +102,25 @@ class Controller extends Application
} }
/**
* @param $methods
* @return mixed
* @throws ComponentException
*/
public function __get($methods)
{
// TODO: Change the autogenerated stub
if (property_exists($this, $methods)) {
return $this->$methods;
}
$method = 'get' . ucfirst($methods);
if (method_exists($this, $method)) {
return $this->{$method}();
}
return Snowflake::app()->get($methods);
}
} }