1 | <?php |
||
12 | class RouteHandler |
||
13 | { |
||
14 | /** |
||
15 | * Handle the action for a route and return the results. |
||
16 | * |
||
17 | * @param string $method the request method. |
||
18 | * @param string $path that was matched. |
||
19 | * @param string|array $action base for the callable. |
||
20 | * @param array $arguments optional arguments. |
||
21 | * @param ContainerInjectableInterface $di container with services. |
||
22 | * |
||
23 | * @return mixed as the result from the route handler. |
||
24 | */ |
||
25 | 110 | public function handle( |
|
59 | |||
60 | |||
61 | |||
62 | /** |
||
63 | * Check if items can be used to call a controller action, verify |
||
64 | * that the controller exists, the action has a class-method to call. |
||
65 | * |
||
66 | * @param string $method the request method. |
||
67 | * @param string $path the matched path, base for the controller action |
||
68 | * and the arguments. |
||
69 | * @param string $class the controller class |
||
70 | * |
||
71 | * @return array with callable details. |
||
72 | */ |
||
73 | 16 | protected function isControllerAction( |
|
100 | |||
101 | |||
102 | |||
103 | /** |
||
104 | * Call the controller action with optional arguments and call |
||
105 | * initialisation methods if available. |
||
106 | * |
||
107 | * @param string $callable with details on what controller action to call. |
||
108 | * |
||
109 | * @return mixed result from the handler. |
||
110 | */ |
||
111 | protected function handleAsControllerAction(array $callable) |
||
133 | |||
134 | |||
135 | |||
136 | /** |
||
137 | * Handle as callable support callables where the method is not static. |
||
138 | * |
||
139 | * @param string|array $action base for the callable |
||
140 | * @param array $arguments optional arguments |
||
141 | * @param ContainerInjectableInterface $di container with services |
||
142 | * |
||
143 | * @return mixed as the result from the route handler. |
||
144 | */ |
||
145 | protected function handleAsCallable( |
||
166 | |||
167 | |||
168 | |||
169 | // /** |
||
170 | // * Load callable as a service from the $di container. |
||
171 | // * |
||
172 | // * @param string|array $action base for the callable |
||
173 | // * @param array $arguments optional arguments |
||
174 | // * @param ContainerInjectableInterface $di container with services |
||
175 | // * |
||
176 | // * @return mixed as the result from the route handler. |
||
177 | // */ |
||
178 | // protected function handleUsingDi( |
||
179 | // $action, |
||
180 | // array $arguments, |
||
181 | // ContainerInjectableInterface $di |
||
182 | // ) { |
||
183 | // if (!$di->has($action[0])) { |
||
184 | // throw new ConfigurationException("Routehandler '{$action[0]}' not loaded in di."); |
||
185 | // } |
||
186 | // |
||
187 | // $service = $di->get($action[0]); |
||
188 | // if (!is_callable([$service, $action[1]])) { |
||
189 | // throw new ConfigurationException( |
||
190 | // "Routehandler '{$action[0]}' does not have a callable method '{$action[1]}'." |
||
191 | // ); |
||
192 | // } |
||
193 | // |
||
194 | // return call_user_func( |
||
195 | // [$service, $action[1]], |
||
196 | // ...$arguments |
||
197 | // ); |
||
198 | // } |
||
199 | } |
||
200 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.