mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
[OPTIMISATION] Optimised router handling - router will now use the order provided when loading routes.
This commit is contained in:
@@ -100,14 +100,6 @@ class RouterBase {
|
||||
// Loop through each route-request
|
||||
$this->processRoutes($this->routes);
|
||||
|
||||
// Make sure the urls is in the right order when comparing
|
||||
usort($this->controllerUrlMap, function($a, $b) {
|
||||
if(stripos($b->getUrl(), '{') !== false) {
|
||||
return $a->getUrl();
|
||||
}
|
||||
return strcmp($b->getUrl(), $a->getUrl());
|
||||
});
|
||||
|
||||
$routeNotAllowed = false;
|
||||
|
||||
/* @var $route RouterEntry */
|
||||
|
||||
@@ -49,7 +49,7 @@ class RouterRoute extends RouterEntry {
|
||||
// Check if url parameter count matches
|
||||
if(stripos($url, $routeMatch) === 0) {
|
||||
|
||||
$matches = true;
|
||||
$matches = (count(explode('/', rtrim($url, '/'))) == count(explode('/', rtrim($route, '/'))));
|
||||
|
||||
if($this->regexMatch) {
|
||||
$parameters = $this->parseParameters($url, true, $this->regexMatch);
|
||||
@@ -62,7 +62,7 @@ class RouterRoute extends RouterEntry {
|
||||
} else {
|
||||
|
||||
$url = explode('/', $url);
|
||||
$route = explode('/', $route);
|
||||
$route = explode('/', rtrim($route, '/'));
|
||||
|
||||
$parameters = array();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user