This commit is contained in:
2020-09-10 15:54:14 +08:00
parent 46b59ebbd1
commit 0abe7eab69
+20 -9
View File
@@ -15,6 +15,7 @@ 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
{ {
@@ -30,6 +31,21 @@ class Controller extends Application
/** @var Request */ /** @var Request */
public $request; public $request;
public $goto;
public $app;
public function __construct($config = [])
{
$this->app = Snowflake::app();
$this->goto = $this->app->goto;
parent::__construct($config);
}
/** /**
* @param HttpParams $input * @param HttpParams $input
*/ */
@@ -97,16 +113,11 @@ class Controller extends Application
*/ */
public function __get($name) public function __get($name)
{ {
$method = 'get' . ucfirst($name); if (property_exists($this, $name)) {
if (method_exists($this, $method)) { return $this->$name;
return $this->$method(); } else if (method_exists($this, $name)) {
return $this->$name();
} }
$app = Snowflake::app();
if ($app->has($name)) {
return $app->get($name);
}
return parent::__get($name); return parent::__get($name);
} }