1 | <?php |
||
34 | class RouteDispatcher implements Dispatcher |
||
35 | { |
||
36 | use AccessorTrait; |
||
37 | |||
38 | /** |
||
39 | * Route collection. |
||
40 | * |
||
41 | * @var RouteCollection |
||
42 | */ |
||
43 | protected $routes; |
||
44 | |||
45 | protected function get_routes() |
||
49 | |||
50 | /** |
||
51 | * @param RouteCollection|null $routes |
||
52 | */ |
||
53 | public function __construct(RouteCollection $routes = null) |
||
57 | |||
58 | /** |
||
59 | * @param Request $request |
||
60 | * |
||
61 | * @return Response|null |
||
62 | */ |
||
63 | public function __invoke(Request $request) |
||
86 | |||
87 | /** |
||
88 | * Normalizes request path. |
||
89 | * |
||
90 | * @param string $path |
||
91 | * |
||
92 | * @return string Decontextualized path with trimmed ending slash. |
||
93 | */ |
||
94 | protected function normalize_path($path) |
||
105 | |||
106 | /** |
||
107 | * Resolves route from request. |
||
108 | * |
||
109 | * @param Request $request |
||
110 | * @param string $normalized_path |
||
111 | * @param array $captured |
||
112 | * |
||
113 | * @return false|Route|null |
||
114 | */ |
||
115 | protected function resolve_route(Request $request, $normalized_path, array &$captured) |
||
119 | |||
120 | /** |
||
121 | * Alters request parameters. |
||
122 | * |
||
123 | * @param Route $route |
||
124 | * @param Request $request |
||
125 | * @param array $captured Parameters captured from the request's path. |
||
126 | */ |
||
127 | protected function alter_params(Route $route, Request $request, array $captured) |
||
132 | |||
133 | /** |
||
134 | * Alters request context with route and controller. |
||
135 | * |
||
136 | * @param Request\Context $context |
||
137 | * @param Route $route |
||
138 | * @param callable $controller |
||
139 | */ |
||
140 | protected function alter_context(Request\Context $context, Route $route, callable $controller) |
||
145 | |||
146 | /** |
||
147 | * Dispatches the route. |
||
148 | * |
||
149 | * @param Route $route |
||
150 | * @param Request $request |
||
151 | * |
||
152 | * @return Response|null |
||
153 | */ |
||
154 | protected function dispatch(Route $route, Request $request) |
||
169 | |||
170 | /** |
||
171 | * Returns a response for the route and request. |
||
172 | * |
||
173 | * If the controller's result is not `null` but is not in instance of {@link Response}, its |
||
174 | * result is wrapped in a {@link response} instance with the status code 200 and the |
||
175 | * `Content-Type` "text/html; charset=utf-8". |
||
176 | * |
||
177 | * @param Route $route |
||
178 | * @param Request $request |
||
179 | * |
||
180 | * @return Response|mixed |
||
181 | */ |
||
182 | protected function respond(Route $route, Request $request) |
||
202 | |||
203 | /** |
||
204 | * Fires {@link \ICanBoogie\Routing\RouteDispatcher\RescueEvent} and returns the response provided |
||
205 | * by third parties. If no response was provided, the exception (or the exception provided by |
||
206 | * third parties) is re-thrown. |
||
207 | * |
||
208 | * @param \Exception $exception The exception to rescue. |
||
209 | * @param Request $request The request being dispatched. |
||
210 | * |
||
211 | * @throws \Exception if the exception cannot be rescued. |
||
212 | * |
||
213 | * @return Response |
||
214 | */ |
||
215 | public function rescue(\Exception $exception, Request $request) |
||
231 | |||
232 | /** |
||
233 | * @param callable|string $controller |
||
234 | * |
||
235 | * @return Controller |
||
236 | */ |
||
237 | protected function resolve_controller($controller) |
||
257 | } |
||
258 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.