diff options
author | msquare <msquare@notrademark.de> | 2018-09-07 20:50:31 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-09-07 20:50:31 +0200 |
commit | 2d6bca1357faff28bc1f86a56b432cc463ff7574 (patch) | |
tree | ce18461d2e170ac28dd365342a1f125a8a31aa3a /src/Middleware/Dispatcher.php | |
parent | b320fc779063ee80b8f0ba505cb323287ccccbf5 (diff) | |
parent | ce6d0fd13b54ac79a955b85d50860736a520d333 (diff) |
Merge branch 'MyIgel-routing'
Diffstat (limited to 'src/Middleware/Dispatcher.php')
-rw-r--r-- | src/Middleware/Dispatcher.php | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/src/Middleware/Dispatcher.php b/src/Middleware/Dispatcher.php index f2a5b5d5..48eb0948 100644 --- a/src/Middleware/Dispatcher.php +++ b/src/Middleware/Dispatcher.php @@ -12,6 +12,8 @@ use Psr\Http\Server\RequestHandlerInterface; class Dispatcher implements MiddlewareInterface, RequestHandlerInterface { + use ResolvesMiddlewareTrait; + /** @var MiddlewareInterface[]|string[] */ protected $stack; @@ -70,10 +72,7 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface throw new LogicException('Middleware queue is empty'); } - if (is_string($middleware)) { - $middleware = $this->resolveMiddleware($middleware); - } - + $middleware = $this->resolveMiddleware($middleware); if (!$middleware instanceof MiddlewareInterface) { throw new InvalidArgumentException('Middleware is no instance of ' . MiddlewareInterface::class); } @@ -82,25 +81,6 @@ class Dispatcher implements MiddlewareInterface, RequestHandlerInterface } /** - * Resolve the middleware with the container - * - * @param string $middleware - * @return MiddlewareInterface - */ - protected function resolveMiddleware($middleware) - { - if (!$this->container instanceof Application) { - throw new InvalidArgumentException('Unable to resolve middleware ' . $middleware); - } - - if ($this->container->has($middleware)) { - return $this->container->get($middleware); - } - - return $this->container->make($middleware); - } - - /** * @param Application $container */ public function setContainer(Application $container) |