1 | <?php |
||
20 | class Route |
||
21 | { |
||
22 | /** |
||
23 | * The pattern to match. |
||
24 | * |
||
25 | * @var string |
||
26 | */ |
||
27 | protected $pattern; |
||
28 | |||
29 | /** |
||
30 | * Any regex rules to apply to placeholders within $pattern. |
||
31 | * |
||
32 | * @var string[] |
||
33 | */ |
||
34 | protected $rules; |
||
35 | |||
36 | /** |
||
37 | * The name of the route. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | protected $name; |
||
42 | |||
43 | /** |
||
44 | * A list of supported methods. |
||
45 | * |
||
46 | * @var string[] |
||
47 | */ |
||
48 | protected $methods; |
||
49 | |||
50 | /** |
||
51 | * The controller that handles the route. |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | protected $controller; |
||
56 | |||
57 | /** |
||
58 | * The action that handles the route. |
||
59 | * |
||
60 | * @var string |
||
61 | */ |
||
62 | protected $action; |
||
63 | |||
64 | /** |
||
65 | * Create a new route. |
||
66 | * |
||
67 | * @param string $name The name of the route. |
||
68 | * @param string $pattern The route pattern string. |
||
69 | * @param string[] $rules Any regex rules to apply to placeholders in $pattern. |
||
70 | * @param string[] $methods The methods that can be used for this route. |
||
71 | * @param string $controller The controller that handles the route. |
||
72 | * @param string $action The action that handles the route. |
||
73 | */ |
||
74 | public function __construct($name, $pattern, array $rules, array $methods, $controller, $action) |
||
92 | |||
93 | /** |
||
94 | * Check if the request matches a defined route pattern. |
||
95 | * |
||
96 | * Returns an array containing any route parameters on a successful match. |
||
97 | * Returns false for failed matches. |
||
98 | * |
||
99 | * @param Request $request The request to check. |
||
100 | * @return array|bool |
||
101 | */ |
||
102 | public function matches(Request $request) |
||
139 | |||
140 | |||
141 | /** |
||
142 | * Generate a URL from a route name and parameter set. |
||
143 | * |
||
144 | * @param array $parameters Optionally the parameters to use. |
||
145 | * @throws \Exception |
||
146 | * @return string|boolean The URL on success, false on failure. |
||
147 | */ |
||
148 | public function generateUrl(array $parameters = array()) |
||
171 | |||
172 | /** |
||
173 | * @param string $action |
||
174 | */ |
||
175 | public function setAction($action) |
||
179 | |||
180 | /** |
||
181 | * @return string |
||
182 | */ |
||
183 | public function getAction() |
||
187 | |||
188 | /** |
||
189 | * @param string $controller |
||
190 | */ |
||
191 | public function setController($controller) |
||
195 | |||
196 | /** |
||
197 | * @return string |
||
198 | */ |
||
199 | public function getController() |
||
203 | |||
204 | /** |
||
205 | * @param string $pattern |
||
206 | */ |
||
207 | public function setPattern($pattern) |
||
211 | |||
212 | /** |
||
213 | * @return string |
||
214 | */ |
||
215 | public function getPattern() |
||
219 | |||
220 | /** |
||
221 | * @param string $name |
||
222 | */ |
||
223 | public function setName($name) |
||
227 | |||
228 | /** |
||
229 | * @return string |
||
230 | */ |
||
231 | public function getName() |
||
235 | |||
236 | /** |
||
237 | * @param string[] $methods |
||
238 | */ |
||
239 | public function setMethods($methods) |
||
243 | |||
244 | /** |
||
245 | * @return string[] |
||
246 | */ |
||
247 | public function getMethods() |
||
251 | } |
||
252 |