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

View File

@@ -237,16 +237,23 @@ class Request
{
$this->rewriteRoute = $route;
$namespace = SimpleRouter::getDefaultNamespace();
$callback = $route->getCallback();
if ($namespace !== null) {
/* Only add default namespace on relative callbacks */
if($callback === null || $callback[0] !== '\\') {
$namespace = SimpleRouter::getDefaultNamespace();
if ($namespace !== null) {
if ($this->rewriteRoute->getNamespace() !== null) {
$namespace .= '\\' . $this->rewriteRoute->getNamespace();
}
$this->rewriteRoute->setDefaultNamespace($namespace);
if ($this->rewriteRoute->getNamespace() !== null) {
$namespace .= '\\' . $this->rewriteRoute->getNamespace();
}
$this->rewriteRoute->setDefaultNamespace($namespace);
}
return $this;