1 | <?php |
||
16 | class InvokerRouterMiddleware implements MiddlewareInterface |
||
17 | { |
||
18 | 1 | public static function createDispatcherFromRouteArray($routes) |
|
29 | |||
30 | /** @var \FastRoute\Dispatcher */ |
||
31 | protected $dispatcher; |
||
32 | |||
33 | /** @var \Invoker\InvokerInterface */ |
||
34 | protected $invoker; |
||
35 | |||
36 | 3 | public function __construct( |
|
43 | |||
44 | 3 | public function process( |
|
45 | ServerRequestInterface $request, |
||
46 | RequestHandlerInterface $handler |
||
47 | ): ResponseInterface { |
||
48 | 3 | list($action, $vars) = $this->getRoute($request); |
|
49 | |||
50 | 1 | foreach ($vars as $key => $value) { |
|
51 | 1 | $request = $request->withAttribute($key, $value); |
|
52 | } |
||
53 | 1 | return $this->invoker->call($action, ['request' => $request]); |
|
54 | } |
||
55 | |||
56 | 3 | private function getRoute(ServerRequestInterface $request) |
|
71 | } |
||
72 |