mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
[BUGFIX] Fixed minor errors with optional parameter when using getRoute().
This commit is contained in:
@@ -376,7 +376,11 @@ abstract class RouterEntry {
|
||||
throw new RouterException(sprintf('Method %s does not exist in class %s', $method, $className), 404);
|
||||
}
|
||||
|
||||
call_user_func_array(array($class, $method), $this->getParameters());
|
||||
$parameters = array_filter($this->getParameters(), function($var){
|
||||
return !is_null($var);
|
||||
});
|
||||
|
||||
call_user_func_array(array($class, $method), $parameters);
|
||||
|
||||
return $class;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,18 @@ class RouterRoute extends RouterEntry {
|
||||
$parameters = $this->parseParameters($route, $url);
|
||||
|
||||
if($parameters !== null) {
|
||||
$this->parameters = $parameters;
|
||||
|
||||
if(is_array($this->parameters)) {
|
||||
$this->parameters = array_merge($this->parameters, $parameters);
|
||||
} else {
|
||||
$this->parameters = $parameters;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user