1 | <?php declare(strict_types=1); |
||
13 | class Dispatcher extends GroupCountBasedDispatcher implements |
||
14 | MiddlewareAwareInterface, |
||
15 | RequestHandlerInterface, |
||
16 | StrategyAwareInterface |
||
17 | { |
||
18 | use MiddlewareAwareTrait; |
||
19 | use StrategyAwareTrait; |
||
20 | |||
21 | /** |
||
22 | * Dispatch the current route |
||
23 | * |
||
24 | * @param ServerRequestInterface $request |
||
25 | * |
||
26 | * @return ResponseInterface |
||
27 | */ |
||
28 | 48 | public function dispatchRequest(ServerRequestInterface $request): ResponseInterface |
|
51 | |||
52 | /** |
||
53 | * @param ServerRequestInterface $request |
||
54 | * @param Route $route |
||
55 | * @return ServerRequestInterface |
||
56 | */ |
||
57 | private function requestWithRouteAttributes(ServerRequestInterface $request, Route $route): ServerRequestInterface |
||
67 | |||
68 | /** |
||
69 | * Ensure handler is a Route, honoring the contract of dispatchRequest. |
||
70 | * |
||
71 | * @param Route|mixed $matchingHandler |
||
72 | 48 | * @param string $httpMethod |
|
73 | * @param string $uri |
||
74 | 48 | * |
|
75 | * @return Route |
||
76 | 48 | * |
|
77 | */ |
||
78 | private function ensureHandlerIsRoute($matchingHandler, $httpMethod, $uri): Route |
||
85 | |||
86 | 24 | /** |
|
87 | * {@inheritdoc} |
||
88 | 24 | */ |
|
89 | 3 | public function handle(ServerRequestInterface $request): ResponseInterface |
|
95 | 24 | ||
96 | 3 | /** |
|
97 | * Set up middleware for a found route |
||
98 | * |
||
99 | * @param Route $route |
||
100 | 24 | * |
|
101 | * @return void |
||
102 | */ |
||
103 | 24 | protected function setFoundMiddleware(Route $route): void |
|
133 | |||
134 | /** |
||
135 | 6 | * Set up middleware for a not found route |
|
136 | * |
||
137 | 6 | * @return void |
|
138 | 6 | */ |
|
139 | protected function setNotFoundDecoratorMiddleware(): void |
||
144 | |||
145 | /** |
||
146 | * Set up middleware for a not allowed route |
||
147 | * |
||
148 | * @param array $allowed |
||
149 | * |
||
150 | * @return void |
||
151 | */ |
||
152 | protected function setMethodNotAllowedDecoratorMiddleware(array $allowed): void |
||
160 | } |
||
161 |