| @@ 436-447 (lines=12) @@ | ||
| 433 | }); |
|
| 434 | ||
| 435 | if (empty(static::$optimized_tree)) { |
|
| 436 | foreach ((array)static::$routes as $group => $routes){ |
|
| 437 | foreach ($routes as $route) { |
|
| 438 | if (is_a($route, 'Route') && false !== ($args = $route->match($URL,$method))){ |
|
| 439 | if ($return_route){ |
|
| 440 | return $route; |
|
| 441 | } else { |
|
| 442 | $route->run($args,$method); |
|
| 443 | return true; |
|
| 444 | } |
|
| 445 | } |
|
| 446 | } |
|
| 447 | } |
|
| 448 | } else { |
|
| 449 | $routes =& static::$optimized_tree; |
|
| 450 | foreach (explode('/',trim($URL,'/')) as $segment) { |
|
| @@ 453-462 (lines=10) @@ | ||
| 450 | foreach (explode('/',trim($URL,'/')) as $segment) { |
|
| 451 | if (isset($routes[$segment])) $routes =& $routes[$segment]; |
|
| 452 | } |
|
| 453 | if (isset($routes[0]) && !is_array($routes[0])) foreach ((array)$routes as $route) { |
|
| 454 | if (false !== ($args = $route->match($URL, $method))){ |
|
| 455 | if ($return_route){ |
|
| 456 | return $route; |
|
| 457 | } else { |
|
| 458 | $route->run($args,$method); |
|
| 459 | return true; |
|
| 460 | } |
|
| 461 | } |
|
| 462 | } |
|
| 463 | } |
|
| 464 | ||
| 465 | Response::status(404, '404 Resource not found.'); |
|