summaryrefslogtreecommitdiff
path: root/src/Middleware/Dispatcher.php
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-25 21:16:20 +0200
committerIgor Scheller <igor.scheller@igorshp.de>2018-08-25 21:48:39 +0200
commita1bc763a16ee8be109de5c9053fbc5eded53824e (patch)
tree7253db0c8ea918e82253bef3926bcba461a7105d /src/Middleware/Dispatcher.php
parent73c9d923e7cc77847cfcbff4b90ad4815699a4fa (diff)
Added nikic/fast-route as routing dispatcher
Diffstat (limited to 'src/Middleware/Dispatcher.php')
-rw-r--r--src/Middleware/Dispatcher.php26
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)