| @@ 524-535 (lines=12) @@ | ||
| 521 | }); |
|
| 522 | ||
| 523 | if (empty(static::$optimized_tree)) { |
|
| 524 | foreach ((array)static::$routes as $group => $routes){ |
|
| 525 | foreach ($routes as $route) { |
|
| 526 | if (is_a($route, 'Route') && $route->match($URL,$method)){ |
|
| 527 | if ($return_route){ |
|
| 528 | return $route; |
|
| 529 | } else { |
|
| 530 | $route->run($route->extractArgs($URL),$method); |
|
| 531 | return true; |
|
| 532 | } |
|
| 533 | } |
|
| 534 | } |
|
| 535 | } |
|
| 536 | } else { |
|
| 537 | $routes =& static::$optimized_tree; |
|
| 538 | foreach (explode('/',trim($URL,'/')) as $segment) { |
|
| @@ 544-553 (lines=10) @@ | ||
| 541 | else if (is_array($routes) && isset($routes[''])) $routes =& $routes['']; |
|
| 542 | else break; |
|
| 543 | } |
|
| 544 | if (is_array($routes) && isset($routes[0]) && !is_array($routes[0])) foreach ((array)$routes as $route) { |
|
| 545 | if (is_a($route, __CLASS__) && $route->match($URL, $method)){ |
|
| 546 | if ($return_route){ |
|
| 547 | return $route; |
|
| 548 | } else { |
|
| 549 | $route->run($route->extractArgs($URL),$method); |
|
| 550 | return true; |
|
| 551 | } |
|
| 552 | } |
|
| 553 | } |
|
| 554 | } |
|
| 555 | ||
| 556 | Response::status(404, '404 Resource not found.'); |
|