Made sure not to iterate over StaticRoutes again because the key they map to is a specific child Handler

This commit is contained in:
Phil 2015-01-01 20:17:48 +00:00
parent 3aca197d7a
commit bb052625af
1 changed files with 12 additions and 9 deletions

View File

@ -49,7 +49,9 @@ class Router implements HandlerInterface
$handler = new $this->routes[$path](); $handler = new $this->routes[$path]();
$response = $handler->getResponse($request, $args); $response = $handler->getResponse($request, $args);
} else { } else {
foreach ($this->routes as $route) { foreach ($this->routes as $path => $route) {
// Only take elements that are not $path => $handler mapped.
if (is_int($path)) {
/** @var HandlerInterface $route */ /** @var HandlerInterface $route */
try { try {
$response = $route->getResponse($request, $args); $response = $route->getResponse($request, $args);
@ -61,6 +63,7 @@ class Router implements HandlerInterface
if ($response) break; if ($response) break;
} }
} }
}
if ($response) { if ($response) {
// Check if the router has an error handler for this status code. // Check if the router has an error handler for this status code.
$status = $response->getStatusCode(); $status = $response->getStatusCode();