mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Small optimisation
This commit is contained in:
@@ -137,6 +137,7 @@ class RouterBase
|
|||||||
protected function processRoutes(array $routes, array $settings = array(), array $prefixes = array(), RouterEntry $parent = null) {
|
protected function processRoutes(array $routes, array $settings = array(), array $prefixes = array(), RouterEntry $parent = null) {
|
||||||
|
|
||||||
$mergedSettings = [];
|
$mergedSettings = [];
|
||||||
|
$mergedPrefixes = [];
|
||||||
|
|
||||||
// Loop through each route-request
|
// Loop through each route-request
|
||||||
/* @var $route RouterEntry */
|
/* @var $route RouterEntry */
|
||||||
@@ -146,6 +147,7 @@ class RouterBase
|
|||||||
|
|
||||||
if ($parent !== null) {
|
if ($parent !== null) {
|
||||||
$route->setParent($parent);
|
$route->setParent($parent);
|
||||||
|
$mergedPrefixes = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($route instanceof ILoadableRoute) {
|
if ($route instanceof ILoadableRoute) {
|
||||||
@@ -159,7 +161,7 @@ class RouterBase
|
|||||||
} elseif ($route instanceof RouterGroup) {
|
} elseif ($route instanceof RouterGroup) {
|
||||||
|
|
||||||
if ($route->getPrefix() !== null && trim($route->getPrefix(), '/') !== '') {
|
if ($route->getPrefix() !== null && trim($route->getPrefix(), '/') !== '') {
|
||||||
$prefixes[] = trim($route->getPrefix(), '/');
|
$mergedPrefixes[] = trim($route->getPrefix(), '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($route->getCallback() !== null && is_callable($route->getCallback())) {
|
if ($route->getCallback() !== null && is_callable($route->getCallback())) {
|
||||||
@@ -186,7 +188,7 @@ class RouterBase
|
|||||||
$this->backStack = array();
|
$this->backStack = array();
|
||||||
|
|
||||||
// Route any routes added to the backstack
|
// Route any routes added to the backstack
|
||||||
$this->processRoutes($backStack, $mergedSettings, $prefixes, $route);
|
$this->processRoutes($backStack, $mergedSettings, $mergedPrefixes, $route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user