1 | <?php |
||
26 | trait ControllerCollectorTrait |
||
27 | { |
||
28 | |||
29 | /** |
||
30 | * @return Parser |
||
31 | */ |
||
32 | |||
33 | abstract public function getParser(); |
||
34 | |||
35 | /** |
||
36 | * @param string $method |
||
37 | * @param string $pattern |
||
38 | * @param callable $action |
||
39 | * |
||
40 | * @return Group |
||
41 | */ |
||
42 | |||
43 | abstract public function set($method, $pattern, $action); |
||
44 | |||
45 | /** |
||
46 | * Define how controller actions names will be joined to form the route pattern. |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | |||
51 | protected $controllerActionJoin = "/"; |
||
52 | |||
53 | /** |
||
54 | * Maps all the controller methods that begins with a HTTP method, and maps the rest of |
||
55 | * name as a path. The path will be the method name with slashes before every camelcased |
||
56 | * word and without the HTTP method prefix, and the controller name will be used to prefix |
||
57 | * the route pattern. e.g. ArticlesController::getCreate will generate a route to: GET articles/create |
||
58 | * |
||
59 | * @param string $controller The controller name |
||
60 | * @param string $prefix |
||
61 | * |
||
62 | * @throws \ReflectionException |
||
63 | * @return Group |
||
64 | */ |
||
65 | |||
66 | 5 | public function controller($controller, $prefix = null) |
|
73 | |||
74 | /** |
||
75 | * Maps several controllers at same time. |
||
76 | * |
||
77 | * @param string[] $controllers Controllers name. |
||
78 | * @throws \ReflectionException |
||
79 | * @return Group |
||
80 | */ |
||
81 | |||
82 | 1 | public function controllers(array $controllers) |
|
89 | |||
90 | /** |
||
91 | * Alias for Collector::controller but maps a controller without using the controller name as prefix. |
||
92 | * |
||
93 | * @param string $controller The controller name |
||
94 | * @throws \ReflectionException |
||
95 | * @return Group |
||
96 | */ |
||
97 | |||
98 | 2 | public function controllerWithoutPrefix($controller) |
|
104 | |||
105 | /** |
||
106 | * Alias for Collector::controllers but maps a controller without using the controller name as prefix. |
||
107 | * |
||
108 | * @param string[] $controllers |
||
109 | * @throws \ReflectionException |
||
110 | * @return Group |
||
111 | */ |
||
112 | |||
113 | 1 | public function controllersWithoutPrefix(array $controllers) |
|
120 | |||
121 | /** |
||
122 | * @param ReflectionClass $controller |
||
123 | * @param ReflectionMethod[] $methods |
||
124 | * @param string $prefix |
||
125 | * |
||
126 | * @return Group |
||
127 | */ |
||
128 | |||
129 | 7 | protected function collectControllerRoutes(ReflectionClass $controller, array $methods, $prefix) |
|
156 | |||
157 | /** |
||
158 | * @param ReflectionClass $controller |
||
159 | * |
||
160 | * @return string |
||
161 | */ |
||
162 | |||
163 | 4 | protected function getControllerPrefix(ReflectionClass $controller) |
|
168 | |||
169 | /** |
||
170 | * @param \ReflectionMethod |
||
171 | * @return string |
||
172 | */ |
||
173 | |||
174 | 7 | protected function getMethodConstraints(ReflectionMethod $method) |
|
194 | |||
195 | /** |
||
196 | * @param ReflectionParameter $parameter |
||
197 | * @param string[] $types |
||
198 | * @return string |
||
199 | */ |
||
200 | |||
201 | 7 | protected function getPathConstraint(ReflectionParameter $parameter, $types) |
|
207 | |||
208 | /** |
||
209 | * @param ReflectionMethod $method |
||
210 | * @return string[] |
||
211 | */ |
||
212 | |||
213 | 7 | protected function getParamsConstraint(ReflectionMethod $method) |
|
226 | |||
227 | /** |
||
228 | * @param ReflectionClass|ReflectionMethod $reflector |
||
229 | * @return string|null |
||
230 | */ |
||
231 | |||
232 | 7 | protected function getAnnotatedStrategy($reflector) |
|
237 | |||
238 | /** |
||
239 | * Define how controller actions names will be joined to form the route pattern. |
||
240 | * Defaults to "/" so actions like "getMyAction" will be "/my/action". If changed to |
||
241 | * "-" the new pattern will be "/my-action". |
||
242 | * |
||
243 | * @param string $join |
||
244 | */ |
||
245 | |||
246 | 1 | public function setControllerActionJoin($join) |
|
250 | |||
251 | /** |
||
252 | * @return string |
||
253 | */ |
||
254 | |||
255 | 1 | public function getControllerActionJoin() |
|
259 | |||
260 | } |
||
261 |