diff --git a/src/Annotate/Delete.php b/src/Annotate/Delete.php index 18c2df0..5684fb1 100644 --- a/src/Annotate/Delete.php +++ b/src/Annotate/Delete.php @@ -35,8 +35,6 @@ class Delete extends AbstractRequestMethod implements InjectRouteInterface { // TODO: Implement dispatch() method. Router::addRoute(RequestMethod::REQUEST_DELETE, $this->path, [$class, $method]); - - $this->registerMiddleware($class, $method); } diff --git a/src/Annotate/Filter.php b/src/Annotate/Filter.php deleted file mode 100644 index 8bc5aa6..0000000 --- a/src/Annotate/Filter.php +++ /dev/null @@ -1,15 +0,0 @@ -path, [$class, $method]); - - $this->registerMiddleware($class, $method); } } diff --git a/src/Annotate/Middleware.php b/src/Annotate/Middleware.php index 865095b..0a047ac 100644 --- a/src/Annotate/Middleware.php +++ b/src/Annotate/Middleware.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Kiri\Router\Annotate; use Kiri\Di\Interface\InjectPropertyInterface; +use Kiri\Router\Base\Middleware as MiddlewareManager; #[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)] class Middleware implements InjectPropertyInterface @@ -21,9 +22,13 @@ class Middleware implements InjectPropertyInterface * @param object $class * @param string $property * @return void + * @throws */ public function dispatch(object $class, string $property): void { + $middlewareManager = \Kiri::getDi()->get(MiddlewareManager::class); + + $middlewareManager->set($class::class, $property, $this->middleware); } diff --git a/src/Annotate/Options.php b/src/Annotate/Options.php index 59f5ae3..6e61568 100644 --- a/src/Annotate/Options.php +++ b/src/Annotate/Options.php @@ -36,8 +36,6 @@ class Options extends AbstractRequestMethod implements InjectRouteInterface { // TODO: Implement dispatch() method. Router::addRoute(RequestMethod::REQUEST_OPTIONS, $this->path, [$class, $method]); - - $this->registerMiddleware($class, $method); } diff --git a/src/Annotate/Other.php b/src/Annotate/Other.php deleted file mode 100644 index 3139bc2..0000000 --- a/src/Annotate/Other.php +++ /dev/null @@ -1,42 +0,0 @@ -method], $this->path, [$class, $method]); - - $this->registerMiddleware($class, $method); - } - - -} diff --git a/src/Annotate/Post.php b/src/Annotate/Post.php index d1a2e36..bbe281f 100644 --- a/src/Annotate/Post.php +++ b/src/Annotate/Post.php @@ -35,8 +35,6 @@ class Post extends AbstractRequestMethod implements InjectRouteInterface { // TODO: Implement dispatch() method. Router::addRoute(RequestMethod::REQUEST_POST, $this->path, [$class, $method]); - - $this->registerMiddleware($class, $method); } diff --git a/src/Annotate/Put.php b/src/Annotate/Put.php index ec2dbb1..6872088 100644 --- a/src/Annotate/Put.php +++ b/src/Annotate/Put.php @@ -35,8 +35,6 @@ class Put extends AbstractRequestMethod implements InjectRouteInterface { // TODO: Implement dispatch() method. Router::addRoute(RequestMethod::REQUEST_PUT, $this->path, [$class, $method]); - - $this->registerMiddleware($class, $method); } } diff --git a/src/Annotate/Route.php b/src/Annotate/Route.php index 7d00ea2..eb66129 100644 --- a/src/Annotate/Route.php +++ b/src/Annotate/Route.php @@ -30,7 +30,5 @@ class Route extends AbstractRequestMethod implements InjectRouteInterface { // TODO: Implement dispatch() method. Router::addRoute($this->method, $this->path, [$class, $method]); - - $this->registerMiddleware($class, $method); } }