1 | <?php |
||
21 | class RouterContainer |
||
22 | { |
||
23 | /** |
||
24 | * |
||
25 | * Generates paths from routes. |
||
26 | * |
||
27 | * @var Generator |
||
28 | * |
||
29 | */ |
||
30 | protected $generator; |
||
31 | |||
32 | /** |
||
33 | * |
||
34 | * Logs activity in the Matcher. |
||
35 | * |
||
36 | * @var Psr\Log\LoggerInterface |
||
37 | * |
||
38 | */ |
||
39 | protected $logger; |
||
40 | |||
41 | /** |
||
42 | * |
||
43 | * A factory to create the logger. |
||
44 | * |
||
45 | * @var callable |
||
46 | * |
||
47 | */ |
||
48 | protected $loggerFactory; |
||
49 | |||
50 | /** |
||
51 | * |
||
52 | * A route map. |
||
53 | * |
||
54 | * @var Map |
||
55 | * |
||
56 | */ |
||
57 | protected $map; |
||
58 | |||
59 | /** |
||
60 | * |
||
61 | * A factory to create the map. |
||
62 | * |
||
63 | * @var callable |
||
64 | * |
||
65 | */ |
||
66 | protected $mapFactory; |
||
67 | |||
68 | /** |
||
69 | * |
||
70 | * The route matcher. |
||
71 | * |
||
72 | * @var Matcher |
||
73 | * |
||
74 | */ |
||
75 | protected $matcher; |
||
76 | |||
77 | /** |
||
78 | * |
||
79 | * A proto-route for the map. |
||
80 | * |
||
81 | * @var Route |
||
82 | * |
||
83 | */ |
||
84 | protected $route; |
||
85 | |||
86 | /** |
||
87 | * |
||
88 | * A factory to create the route. |
||
89 | * |
||
90 | * @var callable |
||
91 | * |
||
92 | */ |
||
93 | protected $routeFactory; |
||
94 | |||
95 | /** |
||
96 | * |
||
97 | * An collection of route-matching rules to iterate through. |
||
98 | * |
||
99 | * @var RuleIterator |
||
100 | * |
||
101 | */ |
||
102 | protected $ruleIterator; |
||
103 | |||
104 | /** |
||
105 | * |
||
106 | * The basepath to use for matching and generating. |
||
107 | * |
||
108 | * @var string |
||
109 | * |
||
110 | */ |
||
111 | protected $basepath; |
||
112 | |||
113 | /** |
||
114 | * |
||
115 | * Constructor. |
||
116 | * |
||
117 | * @param string $basepath The basepath to use for matching and generating. |
||
118 | * |
||
119 | */ |
||
120 | 24 | public function __construct($basepath = null) |
|
132 | |||
133 | /** |
||
134 | * Creates a Logger |
||
135 | * |
||
136 | * @return NullLogger |
||
137 | * |
||
138 | * @access protected |
||
139 | */ |
||
140 | 5 | protected function loggerFactory() |
|
144 | |||
145 | /** |
||
146 | * Creates a new Route |
||
147 | * |
||
148 | * @return Route |
||
149 | * |
||
150 | * @access protected |
||
151 | */ |
||
152 | 24 | protected function routeFactory() |
|
156 | |||
157 | /** |
||
158 | * mapFactory |
||
159 | * |
||
160 | * @return mixed |
||
161 | * |
||
162 | * @access protected |
||
163 | */ |
||
164 | 24 | protected function mapFactory() |
|
168 | |||
169 | /** |
||
170 | * Builds a map |
||
171 | * |
||
172 | * @param Map $map DESCRIPTION |
||
173 | * |
||
174 | * @return mixed |
||
175 | * |
||
176 | * @access protected |
||
177 | */ |
||
178 | 24 | protected function buildMap(Map $map) |
|
182 | |||
183 | /** |
||
184 | * |
||
185 | * Sets the logger factory. |
||
186 | * |
||
187 | * @param callable $loggerFactory The logger factory. |
||
188 | * |
||
189 | * @return null |
||
190 | * |
||
191 | */ |
||
192 | 24 | public function setLoggerFactory(callable $loggerFactory) |
|
196 | |||
197 | /** |
||
198 | * |
||
199 | * Sets the proto-route factory. |
||
200 | * |
||
201 | * @param callable $routeFactory The proto-route factory. |
||
202 | * |
||
203 | * @return null |
||
204 | * |
||
205 | */ |
||
206 | 24 | public function setRouteFactory(callable $routeFactory) |
|
210 | |||
211 | /** |
||
212 | * |
||
213 | * Sets the map factory. |
||
214 | * |
||
215 | * @param callable $mapFactory The map factory. |
||
216 | * |
||
217 | * @return null |
||
218 | * |
||
219 | */ |
||
220 | 24 | public function setMapFactory(callable $mapFactory) |
|
224 | |||
225 | /** |
||
226 | * |
||
227 | * Sets the map builder. |
||
228 | * |
||
229 | * @param callable $mapBuilder The map builder. |
||
230 | * |
||
231 | * @return null |
||
232 | * |
||
233 | */ |
||
234 | 24 | public function setMapBuilder(callable $mapBuilder) |
|
238 | |||
239 | /** |
||
240 | * |
||
241 | * Gets the shared Map instance. Creates it with the map factory, and runs |
||
242 | * it through the map builder, on first call. |
||
243 | * |
||
244 | * @return Map |
||
245 | * |
||
246 | */ |
||
247 | 24 | public function getMap() |
|
248 | { |
||
249 | 24 | if (! $this->map) { |
|
250 | 24 | $this->map = call_user_func($this->mapFactory); |
|
251 | 24 | call_user_func($this->mapBuilder, $this->map); |
|
252 | 24 | } |
|
253 | 24 | return $this->map; |
|
254 | } |
||
255 | |||
256 | /** |
||
257 | * |
||
258 | * Gets the shared Matcher instance. |
||
259 | * |
||
260 | * @return Matcher |
||
261 | * |
||
262 | */ |
||
263 | 5 | public function getMatcher() |
|
274 | |||
275 | /** |
||
276 | * |
||
277 | * Gets the shared Generator instance. |
||
278 | * |
||
279 | * @return Generator |
||
280 | * |
||
281 | */ |
||
282 | 14 | public function getGenerator() |
|
289 | |||
290 | /** |
||
291 | * |
||
292 | * Gets the shared Logger instance. |
||
293 | * |
||
294 | * @return Logger |
||
295 | * |
||
296 | */ |
||
297 | 5 | public function getLogger() |
|
304 | |||
305 | /** |
||
306 | * |
||
307 | * Gets the shared proto-route instance. |
||
308 | * |
||
309 | * @return Route |
||
310 | * |
||
311 | */ |
||
312 | 24 | public function getRoute() |
|
319 | |||
320 | /** |
||
321 | * |
||
322 | * Gets the rule iterator instance. |
||
323 | * |
||
324 | * @return RuleIterator |
||
325 | * |
||
326 | */ |
||
327 | 5 | public function getRuleIterator() |
|
340 | |||
341 | /** |
||
342 | * |
||
343 | * Gets a new route generation helper |
||
344 | * |
||
345 | * @return Helper\Route |
||
346 | * |
||
347 | */ |
||
348 | 1 | public function newRouteHelper() |
|
352 | |||
353 | /** |
||
354 | * |
||
355 | * Gets a new raw route generation helper |
||
356 | * |
||
357 | * @return Helper\RouteRaw |
||
358 | * |
||
359 | */ |
||
360 | 1 | public function newRouteRawHelper() |
|
364 | } |
||
365 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.