From 9805d06d48c9d37c75ff7cb1dc4515d0867f1459 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=91=E6=9E=97?= Date: Sun, 16 Apr 2023 13:26:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=98=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Base/Middleware.php | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/src/Base/Middleware.php b/src/Base/Middleware.php index 5375a20..465e3a5 100644 --- a/src/Base/Middleware.php +++ b/src/Base/Middleware.php @@ -29,12 +29,11 @@ class Middleware /** * @param string $className * @param string $method - * @param string $middleware - * @param array $construct + * @param string|object $middleware * @return void * @throws Exception */ - public function set(string $className, string $method, string $middleware, array $construct = []): void + public function set(string $className, string $method, string|object $middleware): void { $path = $className . '::' . $method; if ($this->map->has($path)) { @@ -46,7 +45,7 @@ class Middleware return; } } - $this->map->append($path, [$middleware, $construct]); + $this->map->append($path, $middleware); } @@ -57,28 +56,8 @@ class Middleware */ public function get(string $className, string $method): array { - return $this->routeMap->get($className . '::' . $method) ?? []; + return $this->map->get($className . '::' . $method) ?? []; } - /** - * @param string $path - * @param mixed $middleware - * @return void - * @throws Exception - */ - public function addPathMiddleware(string $path, string $middleware): void - { - if ($this->routeMap->has($path)) { - $values = $this->routeMap->get($path); - if (in_array($middleware, $values)) { - return; - } - if (!in_array(MiddlewareInterface::class, class_implements($middleware))) { - return; - } - } - $this->routeMap->append($path, $middleware); - } - }