Development

- Fixed: only set default namespace on relative callbacks.
- Fixed: default-namespace not being set when calling `SimpleRouter::resource`.
- Minor optimisations.
This commit is contained in:
Simon Sessingø
2017-02-15 03:28:34 +01:00
parent c87298ee24
commit 2a448fccd2
5 changed files with 42 additions and 20 deletions
+9 -4
View File
@@ -57,16 +57,21 @@ abstract class Route implements IRoute
public function renderRoute(Request $request)
{
if ($this->getCallback() !== null && is_callable($this->getCallback())) {
$callback = $this->getCallback();
if ($callback !== null && is_callable($callback)) {
/* When the callback is a function */
call_user_func_array($this->getCallback(), $this->getParameters());
call_user_func_array($callback, $this->getParameters());
} else {
/* When the callback is a method */
$controller = explode('@', $this->getCallback());
$className = $this->getNamespace() . '\\' . $controller[0];
$controller = explode('@', $callback);
$namespace = $this->getNamespace();
$className = ($namespace !== null) ? $namespace . '\\' . $controller[0] : $controller[0];
$class = $this->loadClass($className);
$method = $controller[1];