| @@ 462-473 (lines=12) @@ | ||
| 459 | }); |
|
| 460 | ||
| 461 | if (empty(static::$optimized_tree)) { |
|
| 462 | foreach ((array)static::$routes as $group => $routes){ |
|
| 463 | foreach ($routes as $route) { |
|
| 464 | if (is_a($route, 'Route') && $route->match($URL,$method)){ |
|
| 465 | if ($return_route){ |
|
| 466 | return $route; |
|
| 467 | } else { |
|
| 468 | $route->run($route->extractArgs($URL),$method); |
|
| 469 | return true; |
|
| 470 | } |
|
| 471 | } |
|
| 472 | } |
|
| 473 | } |
|
| 474 | } else { |
|
| 475 | $routes =& static::$optimized_tree; |
|
| 476 | foreach (explode('/',trim($URL,'/')) as $segment) { |
|
| @@ 479-488 (lines=10) @@ | ||
| 476 | foreach (explode('/',trim($URL,'/')) as $segment) { |
|
| 477 | if (isset($routes[$segment])) $routes =& $routes[$segment]; else break; |
|
| 478 | } |
|
| 479 | if (isset($routes[0]) && !is_array($routes[0])) foreach ((array)$routes as $route) { |
|
| 480 | if ($route->match($URL, $method)){ |
|
| 481 | if ($return_route){ |
|
| 482 | return $route; |
|
| 483 | } else { |
|
| 484 | $route->run($route->extractArgs($URL),$method); |
|
| 485 | return true; |
|
| 486 | } |
|
| 487 | } |
|
| 488 | } |
|
| 489 | } |
|
| 490 | ||
| 491 | Response::status(404, '404 Resource not found.'); |
|