1 | <?php |
||
32 | class ActionMapping implements ActionMappingInterface |
||
33 | { |
||
34 | |||
35 | /** |
||
36 | * The template for to create the compiled regex from. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $regexTemplate = '/^%s$/'; |
||
41 | |||
42 | /** |
||
43 | * The path with the controller/method name. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | protected $path; |
||
48 | |||
49 | /** |
||
50 | * The uncompiled expression. |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $expression; |
||
55 | |||
56 | /** |
||
57 | * The compiled regex, used to extract the variables from the route. |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $compiledRegex; |
||
62 | |||
63 | /** |
||
64 | * The controller name, extracted from the route. |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $controllerName; |
||
69 | |||
70 | /** |
||
71 | * The method name, extracted from the route. |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | protected $methodName; |
||
76 | |||
77 | /** |
||
78 | * The array containing the declared placeholders. |
||
79 | * |
||
80 | * @var array |
||
81 | */ |
||
82 | protected $vars = array(); |
||
83 | |||
84 | /** |
||
85 | * The array with the default values for the placeholders. |
||
86 | * |
||
87 | * @var array |
||
88 | */ |
||
89 | protected $defaults = array(); |
||
90 | |||
91 | /** |
||
92 | * The request parameters, extracted from the route. |
||
93 | * |
||
94 | * @var array |
||
95 | */ |
||
96 | protected $requestParameters = array(); |
||
97 | |||
98 | /** |
||
99 | * Compiles the passed route expression into a valid regex. |
||
100 | * |
||
101 | * @param string $expression The expression to use |
||
102 | * @param array $requirements The requirements for the expression |
||
103 | * @param array $defaults The default values for the found variables |
||
104 | * |
||
105 | * @return void |
||
106 | */ |
||
107 | public function compile($expression, array $requirements = array(), array $defaults = array()) |
||
158 | |||
159 | /** |
||
160 | * Tokenizes the passed route by using the tokenizers expression. |
||
161 | * |
||
162 | * @param string $route The route to be parsed |
||
163 | * |
||
164 | * @return boolean TRUE if the passed route matches the expression, else FALSE |
||
165 | */ |
||
166 | public function match($route) |
||
190 | |||
191 | /** |
||
192 | * Return's the path with the controller/method name. |
||
193 | * |
||
194 | * @return string The path with the controller/method name |
||
195 | */ |
||
196 | protected function getPath() |
||
200 | |||
201 | /** |
||
202 | * If necessary, this method applies the default values to the passed route. |
||
203 | * |
||
204 | * @param string $route The route to apply the default values to |
||
205 | * |
||
206 | * @return string The route with the default values applied |
||
207 | */ |
||
208 | protected function applyDefaults($route) |
||
240 | |||
241 | /** |
||
242 | * Return's the regex build from the expression. |
||
243 | * |
||
244 | * @return string The regex |
||
245 | */ |
||
246 | public function getCompiledRegex() |
||
250 | |||
251 | /** |
||
252 | * Initializes the action mapping with the passed controller name. |
||
253 | * |
||
254 | * @param string $controllerName The controller name found in the route |
||
255 | * |
||
256 | * @return void |
||
257 | */ |
||
258 | public function setControllerName($controllerName) |
||
262 | |||
263 | /** |
||
264 | * Return's the controller name found in the route. |
||
265 | * |
||
266 | * @return string The controller name |
||
267 | */ |
||
268 | public function getControllerName() |
||
272 | |||
273 | /** |
||
274 | * Initializes the action mapping with the passed method name. |
||
275 | * |
||
276 | * @param string $methodName The method name found in the route |
||
277 | * |
||
278 | * @return void |
||
279 | */ |
||
280 | public function setMethodName($methodName) |
||
284 | |||
285 | /** |
||
286 | * Return's the method name found in the route. |
||
287 | * |
||
288 | * @return string The method name |
||
289 | */ |
||
290 | public function getMethodName() |
||
294 | |||
295 | /** |
||
296 | * Return's the extracted request parameters found in the route. |
||
297 | * |
||
298 | * @return array The extracted request parameters |
||
299 | */ |
||
300 | public function getRequestParameters() |
||
304 | } |
||
305 |