1 | <?php |
||
11 | trait RouteAction |
||
12 | { |
||
13 | /** |
||
14 | * Get request, set for controller |
||
15 | * |
||
16 | * @return ServerRequestInterface |
||
17 | */ |
||
18 | abstract public function getRequest(); |
||
19 | |||
20 | /** |
||
21 | * Get response. set for controller |
||
22 | * |
||
23 | * @return ResponseInterface |
||
24 | */ |
||
25 | abstract public function getResponse(); |
||
26 | |||
27 | /** |
||
28 | * Run the controller |
||
29 | * |
||
30 | * @return ResponseInterface |
||
31 | */ |
||
32 | 9 | public function run() { |
|
53 | |||
54 | /** |
||
55 | * Get the method name of the action |
||
56 | * |
||
57 | * @param string $action |
||
58 | * @return string |
||
59 | */ |
||
60 | 9 | protected function getActionMethod($action) |
|
64 | |||
65 | /** |
||
66 | * Get the arguments for a function from a route using reflection |
||
67 | * |
||
68 | * @param object $route |
||
69 | * @param \ReflectionFunctionAbstract $refl |
||
70 | * @return array |
||
71 | */ |
||
72 | 6 | protected function getFunctionArgs($route, \ReflectionFunctionAbstract $refl) |
|
99 | |||
100 | /** |
||
101 | * Set response to error state |
||
102 | * |
||
103 | * @param int $code |
||
104 | * @param string $message |
||
105 | * @return ResponseInterface |
||
106 | */ |
||
107 | 3 | protected function setResponseError($code, $message) |
|
116 | } |
||
117 | |||
118 |