From ce1952d796fcdca7eca98411adb9845f5a1d139a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Mon, 2 Aug 2021 18:43:12 +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 --- Annotation/Aspect.php | 2 +- HttpServer/Route/Node.php | 3 +-- System/Aop.php | 1 + function.php | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Annotation/Aspect.php b/Annotation/Aspect.php index 12b76d05..3f3cb6f0 100644 --- a/Annotation/Aspect.php +++ b/Annotation/Aspect.php @@ -38,7 +38,7 @@ defined('ASPECT_ERROR') or define('ASPECT_ERROR', 'Aspect annotation must implem throw new Exception(ASPECT_ERROR . IAspect::class); } /** @var Aop $aop */ - $aop = Snowflake::app()->get('aop'); + $aop = Snowflake::app()->get(Aop::class); $aop->aop_add([$class, $method], $this->aspect); diff --git a/HttpServer/Route/Node.php b/HttpServer/Route/Node.php index 0131047a..39e17697 100644 --- a/HttpServer/Route/Node.php +++ b/HttpServer/Route/Node.php @@ -163,8 +163,7 @@ class Node extends HttpService private function createDispatch(): Closure { /** @var Aop $aop */ - $aop = Snowflake::app()->get('aop'); - var_dump($this->path . '->' . (int)$aop->hasAop($this->handler)); + $aop = Snowflake::app()->get(Aop::class); if ($this->handler instanceof Closure || !$aop->hasAop($this->handler)) { return $this->normalHandler($this->handler); } else { diff --git a/System/Aop.php b/System/Aop.php index 401fc9ea..c76e227e 100644 --- a/System/Aop.php +++ b/System/Aop.php @@ -34,6 +34,7 @@ class Aop extends Component if (!isset(static::$_aop[$alias])) { static::$_aop[$alias] = []; } + var_dump($alias, $aspect); if (in_array($aspect, static::$_aop[$alias])) { return; } diff --git a/function.php b/function.php index e1c85d2a..6e152f22 100644 --- a/function.php +++ b/function.php @@ -10,6 +10,7 @@ use HttpServer\Http\Response; use HttpServer\Route\Router; use JetBrains\PhpStorm\Pure; use Snowflake\Abstracts\Config; +use Snowflake\Aop; use Snowflake\Application; use Snowflake\Core\ArrayAccess; use Snowflake\Core\Json; @@ -312,7 +313,7 @@ if (!function_exists('aop')) { */ function aop(mixed $handler, array $params = []): mixed { - return Snowflake::app()->get('aop')->dispatch($handler, $params); + return Snowflake::getDi()->get(Aop::class)->dispatch($handler, $params); } }