From 0abe7eab69c73a37642bf3ad75dae21c4084c128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 10 Sep 2020 15:54:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HttpServer/Controller.php | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/HttpServer/Controller.php b/HttpServer/Controller.php index e45baa84..9d2044f5 100644 --- a/HttpServer/Controller.php +++ b/HttpServer/Controller.php @@ -15,6 +15,7 @@ use Snowflake\Snowflake; * Class WebController * @package Snowflake\Snowflake\Web * @property BaseGoto $goto + * @property \Snowflake\Application $app */ class Controller extends Application { @@ -30,6 +31,21 @@ class Controller extends Application /** @var 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 */ @@ -97,16 +113,11 @@ class Controller extends Application */ public function __get($name) { - $method = 'get' . ucfirst($name); - if (method_exists($this, $method)) { - return $this->$method(); + if (property_exists($this, $name)) { + return $this->$name; + } else if (method_exists($this, $name)) { + return $this->$name(); } - - $app = Snowflake::app(); - if ($app->has($name)) { - return $app->get($name); - } - return parent::__get($name); }