From 6271e8d47a72342f4d24d979e991a309c0559b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 10 Sep 2020 15:49:42 +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 | 6 ++++++ System/Abstracts/BaseApplication.php | 4 +++- System/Abstracts/BaseGoto.php | 27 +++++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 System/Abstracts/BaseGoto.php diff --git a/HttpServer/Controller.php b/HttpServer/Controller.php index f3b8647c..5ff1c278 100644 --- a/HttpServer/Controller.php +++ b/HttpServer/Controller.php @@ -99,6 +99,12 @@ class Controller extends Application if (method_exists($this, $method)) { return $this->$method(); } + + $app = Snowflake::app(); + if ($app->has($name)) { + return $app->get($name); + } + return parent::__get($name); } diff --git a/System/Abstracts/BaseApplication.php b/System/Abstracts/BaseApplication.php index 471543f8..0902d989 100644 --- a/System/Abstracts/BaseApplication.php +++ b/System/Abstracts/BaseApplication.php @@ -45,6 +45,7 @@ use Database\DatabasesProviders; * @property Memcached $memcached * @property Logger $logger * @property Jwt $jwt + * @property BaseGoto $goto */ abstract class BaseApplication extends Service { @@ -371,7 +372,8 @@ abstract class BaseApplication extends Service 'logger' => ['class' => Logger::class], 'router' => ['class' => Router::class], 'redis' => ['class' => Redis::class], - 'jwt' => ['class' => Jwt::class] + 'jwt' => ['class' => Jwt::class], + 'goto' => ['class' => BaseGoto::class] ]); } } diff --git a/System/Abstracts/BaseGoto.php b/System/Abstracts/BaseGoto.php new file mode 100644 index 00000000..bb616111 --- /dev/null +++ b/System/Abstracts/BaseGoto.php @@ -0,0 +1,27 @@ +