Added parameter support for Group routes.

This commit is contained in:
Simon Sessingø
2017-09-03 16:37:20 +01:00
parent 52e0f5ef94
commit 3a90578351
5 changed files with 74 additions and 34 deletions
+24 -27
View File
@@ -129,15 +129,27 @@ class Router
$route = $routes[$i];
if ($parent !== null) {
/* Add the parent route */
$route->setParent($parent);
/* Add/merge parent settings with child */
$route->setSettings($parent->toArray(), true);
}
if ($group !== null) {
/* Add the parent group */
$route->setGroup($group);
}
/* @var $route IGroupRoute */
if ($route instanceof IGroupRoute) {
$group = $route;
$this->processingRoute = true;
$route->renderRoute($this->request);
$this->processingRoute = false;
if ($route->matchRoute($url, $this->request) === true) {
/* Add exception handlers */
@@ -147,22 +159,10 @@ class Router
}
}
}
if ($group !== null) {
/* Add the parent group */
$route->setGroup($group);
}
if ($parent !== null) {
/* Add the parent route */
$route->setParent($parent);
/* Add/merge parent settings with child */
$route->setSettings($parent->toArray(), true);
$this->processingRoute = true;
$route->renderRoute($this->request);
$this->processingRoute = false;
}
if ($route instanceof ILoadableRoute) {
@@ -258,9 +258,7 @@ class Router
if ($rewriteUrl !== null && $rewriteUrl !== $url) {
unset($this->processedRoutes[$i]);
$this->processedRoutes = array_values($this->processedRoutes);
$this->routeRequest(true);
return;
return $this->routeRequest(true);
}
/* Render route */
@@ -268,8 +266,6 @@ class Router
$this->request->setLoadedRoute($route);
return $route->renderRoute($this->request);
break;
}
}
@@ -293,12 +289,15 @@ class Router
$this->handleException(new NotFoundHttpException($message, 404));
}
return null;
}
/**
* @param \Exception $e
* @throws HttpException
* @throws \Exception
* @return string
*/
protected function handleException(\Exception $e)
{
@@ -335,9 +334,7 @@ class Router
if ($rewriteUrl !== null && $rewriteUrl !== $url) {
unset($this->exceptionHandlers[$i]);
$this->exceptionHandlers = array_values($this->exceptionHandlers);
$this->routeRequest(true);
return;
return $this->routeRequest(true);
}
}
}