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 | 11 | 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 | 10 | 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 | 10 | protected function applyDefaults($route) |
|
239 | |||
240 | /** |
||
241 | * Return's the regex build from the expression. |
||
242 | * |
||
243 | * @return string The regex |
||
244 | */ |
||
245 | 10 | public function getCompiledRegex() |
|
249 | |||
250 | /** |
||
251 | * Initializes the action mapping with the passed controller name. |
||
252 | * |
||
253 | * @param string $controllerName The controller name found in the route |
||
254 | * |
||
255 | * @return void |
||
256 | */ |
||
257 | 2 | public function setControllerName($controllerName) |
|
261 | |||
262 | /** |
||
263 | * Return's the controller name found in the route. |
||
264 | * |
||
265 | * @return string The controller name |
||
266 | */ |
||
267 | 1 | public function getControllerName() |
|
271 | |||
272 | /** |
||
273 | * Initializes the action mapping with the passed method name. |
||
274 | * |
||
275 | * @param string $methodName The method name found in the route |
||
276 | * |
||
277 | * @return void |
||
278 | */ |
||
279 | 2 | public function setMethodName($methodName) |
|
283 | |||
284 | /** |
||
285 | * Return's the method name found in the route. |
||
286 | * |
||
287 | * @return string The method name |
||
288 | */ |
||
289 | 1 | public function getMethodName() |
|
293 | |||
294 | /** |
||
295 | * Return's the extracted request parameters found in the route. |
||
296 | * |
||
297 | * @return array The extracted request parameters |
||
298 | */ |
||
299 | 10 | public function getRequestParameters() |
|
303 | } |
||
304 |