| @@ 275-291 (lines=17) @@ | ||
| 272 | # |
|
| 273 | # Search for a matching static route. |
|
| 274 | # |
|
| 275 | $map_static = function($definitions) use($path, &$matchable) { |
|
| 276 | ||
| 277 | foreach ($definitions as $id => $definition) |
|
| 278 | { |
|
| 279 | $pattern = $definition[RouteDefinition::PATTERN]; |
|
| 280 | $via = $definition[RouteDefinition::VIA]; |
|
| 281 | ||
| 282 | if (!$matchable($via) || $pattern != $path) |
|
| 283 | { |
|
| 284 | continue; |
|
| 285 | } |
|
| 286 | ||
| 287 | return $id; |
|
| 288 | } |
|
| 289 | ||
| 290 | return null; |
|
| 291 | }; |
|
| 292 | ||
| 293 | # |
|
| 294 | # Search for a matching dynamic route. |
|
| @@ 296-312 (lines=17) @@ | ||
| 293 | # |
|
| 294 | # Search for a matching dynamic route. |
|
| 295 | # |
|
| 296 | $map_dynamic = function($definitions) use($path, &$matchable, &$captured) { |
|
| 297 | ||
| 298 | foreach ($definitions as $id => $definition) |
|
| 299 | { |
|
| 300 | $pattern = $definition[RouteDefinition::PATTERN]; |
|
| 301 | $via = $definition[RouteDefinition::VIA]; |
|
| 302 | ||
| 303 | if (!$matchable($via) || !Pattern::from($pattern)->match($path, $captured)) |
|
| 304 | { |
|
| 305 | continue; |
|
| 306 | } |
|
| 307 | ||
| 308 | return $id; |
|
| 309 | } |
|
| 310 | ||
| 311 | return null; |
|
| 312 | }; |
|
| 313 | ||
| 314 | list($static, $dynamic) = $this->sort_routes(); |
|
| 315 | ||