mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
[OPTIMISATION] Optimised routes loop.
This commit is contained in:
@@ -38,13 +38,17 @@ class RouterBase {
|
||||
}
|
||||
}
|
||||
|
||||
protected function processRoutes(array $routes, array $settings = array(), array $prefixes = array(), $backstack = false, $group = null) {
|
||||
protected function processRoutes(array $routes, array $settings = array(), array $prefixes = array(), $backStack = false, $group = null) {
|
||||
// Loop through each route-request
|
||||
|
||||
$activeGroup = null;
|
||||
|
||||
$routesCount = count($routes);
|
||||
|
||||
/* @var $route RouterEntry */
|
||||
foreach($routes as $route) {
|
||||
for($i = 0; $i < $routesCount; $i++) {
|
||||
|
||||
$route = $routes[$i];
|
||||
|
||||
$route->setGroup($group);
|
||||
|
||||
@@ -68,7 +72,7 @@ class RouterBase {
|
||||
$route->addSettings($settings);
|
||||
|
||||
if(!($route instanceof RouterGroup)) {
|
||||
if(is_array($newPrefixes) && count($newPrefixes) && $backstack) {
|
||||
if(is_array($newPrefixes) && count($newPrefixes) && $backStack) {
|
||||
$route->setUrl( join('/', $newPrefixes) . $route->getUrl() );
|
||||
}
|
||||
|
||||
@@ -84,11 +88,11 @@ class RouterBase {
|
||||
$this->currentRoute = null;
|
||||
|
||||
if(count($this->backstack)) {
|
||||
$backstack = $this->backstack;
|
||||
$backStack = $this->backstack;
|
||||
$this->backstack = array();
|
||||
|
||||
// Route any routes added to the backstack
|
||||
$this->processRoutes($backstack, $mergedSettings, $newPrefixes, true, $activeGroup);
|
||||
$this->processRoutes($backStack, $mergedSettings, $newPrefixes, true, $activeGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user