From cc0a1ec7b577b048f15fd0a430499ee515b201e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Tue, 8 Sep 2020 11:55:04 +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/Route/Annotation/Annotation.php | 68 ++++++++++------------ 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/HttpServer/Route/Annotation/Annotation.php b/HttpServer/Route/Annotation/Annotation.php index 79cd8bc9..63136a57 100644 --- a/HttpServer/Route/Annotation/Annotation.php +++ b/HttpServer/Route/Annotation/Annotation.php @@ -39,7 +39,7 @@ class Annotation extends \Snowflake\Annotation\Annotation private $Middleware = ''; -// private $After = ''; + private $After = ''; protected $_annotations = []; @@ -87,9 +87,9 @@ class Annotation extends \Snowflake\Annotation\Annotation case 'Limits': $this->bindLimits($node, $annotation); break; -// case 'After': -// $this->bindAfter($node, $annotation); -// break; + case 'After': + $this->bindAfter($node, $annotation); + break; } } @@ -161,38 +161,34 @@ class Annotation extends \Snowflake\Annotation\Annotation $node->addInterceptor($this->pop($this->getName(...$params))); } } -// -// -// /** -// * @param Node $node -// * @param $annotation -// * @throws -// */ -// private function bindAfter($node, $annotation) -// { -// if (!isset($annotation[1][2])) { -// return; -// } -// -// $explode = explode(',', $annotation[1][2]); -// -// [$keyName, $matchs] = $annotation; -// foreach ($explode as $middleware) { -// $middleware = 'App\Http\Interceptor\\' . $middleware; -// if (!class_exists($middleware)) { -// continue; -// } -// $middleware = Snowflake::createObject($middleware); -// if (!($middleware instanceof Interceptor)) { -// continue; -// } -// $node->addAfter([$middleware, 'Interceptor']); -// continue; -// -// $params = [$keyName, [$matchs[0], $matchs[1], $middleware]]; -// $node->addInterceptor($this->pop($this->getName(...$params))); -// } -// } + + + /** + * @param Node $node + * @param $annotation + * @throws + */ + private function bindAfter($node, $annotation) + { + if (!isset($annotation[1][2])) { + return; + } + + $explode = explode(',', $annotation[1][2]); + + [$keyName, $matchs] = $annotation; + foreach ($explode as $middleware) { + $middleware = 'App\Http\Interceptor\\' . $middleware; + if (!class_exists($middleware)) { + continue; + } + $middleware = Snowflake::createObject($middleware); + if (!($middleware instanceof Interceptor)) { + continue; + } + $node->addAfter([$middleware, 'Interceptor']); + } + } /**