eee
This commit is contained in:
+13
-3
@@ -8,6 +8,7 @@ namespace Kiri\Router;
|
|||||||
use Closure;
|
use Closure;
|
||||||
use Kiri\Router\Base\NotFoundController;
|
use Kiri\Router\Base\NotFoundController;
|
||||||
use Kiri\Router\Constrict\RequestMethod;
|
use Kiri\Router\Constrict\RequestMethod;
|
||||||
|
use Psr\Http\Server\MiddlewareInterface;
|
||||||
use ReflectionException;
|
use ReflectionException;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
use Traversable;
|
use Traversable;
|
||||||
@@ -232,11 +233,20 @@ class RouterCollector implements \ArrayAccess, \IteratorAggregate
|
|||||||
$attributes = $reflect->getMethod($method)->getAttributes(Annotate\Middleware::class);
|
$attributes = $reflect->getMethod($method)->getAttributes(Annotate\Middleware::class);
|
||||||
|
|
||||||
foreach ($attributes as $attribute) {
|
foreach ($attributes as $attribute) {
|
||||||
if (!in_array($attribute->getName(), $response)) {
|
/** @var Annotate\Middleware $instance */
|
||||||
$response[] = $attribute->getName();
|
$instance = $attribute->newInstance();
|
||||||
}
|
|
||||||
|
$data = $instance->middleware;
|
||||||
|
if (is_string($data)) {
|
||||||
|
$data = [$data];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($data as $middleware) {
|
||||||
|
if (!in_array($middleware, $response)) {
|
||||||
|
$response[] = $middleware;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user