mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 20:02:13 +00:00
[BUGFIX] Optimisations + bugfixes.
This commit is contained in:
@@ -80,11 +80,13 @@ class RouterBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->currentRoute = $route;
|
$this->currentRoute = $route;
|
||||||
|
|
||||||
if($route instanceof RouterGroup && is_callable($route->getCallback())) {
|
if($route instanceof RouterGroup && is_callable($route->getCallback())) {
|
||||||
$route->renderRoute($this->request);
|
$route->renderRoute($this->request);
|
||||||
$activeGroup = $route;
|
$activeGroup = $route;
|
||||||
$mergedSettings = array_merge($settings, $route->getMergeableSettings());
|
$mergedSettings = array_merge($route->getMergeableSettings(), $settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->currentRoute = null;
|
$this->currentRoute = null;
|
||||||
|
|
||||||
if(count($this->backstack)) {
|
if(count($this->backstack)) {
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ abstract class RouterEntry {
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getParameters(){
|
public function getParameters(){
|
||||||
return $this->parameters;
|
return ($this->parameters === null) ? array() : $this->parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -254,7 +254,8 @@ abstract class RouterEntry {
|
|||||||
$parameterRegex = $this->parametersRegex[$parameter];
|
$parameterRegex = $this->parametersRegex[$parameter];
|
||||||
}
|
}
|
||||||
|
|
||||||
for($i = 0; $i < strlen($route); $i++) {
|
$routeLength = strlen($route);
|
||||||
|
for($i = 0; $i < $routeLength; $i++) {
|
||||||
|
|
||||||
$character = $route[$i];
|
$character = $route[$i];
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ class RouterRoute extends RouterEntry {
|
|||||||
* @return self
|
* @return self
|
||||||
*/
|
*/
|
||||||
public function setUrl($url) {
|
public function setUrl($url) {
|
||||||
|
|
||||||
$parameters = array();
|
$parameters = array();
|
||||||
$matches = array();
|
$matches = array();
|
||||||
|
|
||||||
@@ -72,12 +71,12 @@ class RouterRoute extends RouterEntry {
|
|||||||
$parameters = $matches[1];
|
$parameters = $matches[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
$max = count($parameters);
|
if(count($parameters)) {
|
||||||
if($max) {
|
$tmp = array();
|
||||||
for($i = 0; $i < $max; $i++) {
|
foreach($parameters as $param) {
|
||||||
$param = $parameters[$i];
|
$tmp[$param] = '';
|
||||||
$this->parameters[$param] = '';
|
|
||||||
}
|
}
|
||||||
|
$this->parameters = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
|
|||||||
Reference in New Issue
Block a user