- Array arguments are now longer automaticially merged.
- Added domain-route parameter unit-test.
This commit is contained in:
Simon Sessingø
2016-11-17 03:50:33 +01:00
parent b5f8d9410f
commit 73ee4521bc
10 changed files with 303 additions and 287 deletions
+14 -20
View File
@@ -126,7 +126,7 @@ class RouterBase {
$route = $routes[$i];
if(count($settings)) {
$route->addSettings($settings);
$route->setData($settings);
}
if($parent !== null) {
@@ -135,15 +135,6 @@ class RouterBase {
if ($parent->getPrefix() !== null && trim($parent->getPrefix(), '/') !== '') {
$prefixes[] = trim($parent->getPrefix(), '/');
}
if ($route->matchRoute($this->request)) {
$mergedSettings = array_merge($settings, $parent->getMergeableSettings());
// Add ExceptionHandler
if (count($parent->getExceptionHandlers())) {
$this->exceptionHandlers = array_merge($this->exceptionHandlers, $parent->getExceptionHandler());
}
}
}
$route->setParent($parent);
@@ -161,11 +152,20 @@ class RouterBase {
if($route instanceof ILoadableRoute) {
$route->setUrl( trim(join('/', $prefixes) . $route->getUrl(), '/') );
$this->controllerUrlMap[] = $route;
} else {
} elseif($route instanceof RouterGroup) {
if ($route->getCallback() !== null && is_callable($route->getCallback())) {
$this->processingRoute = true;
$route->renderRoute($this->request);
$this->processingRoute = false;
if ($route->matchRoute($this->request)) {
$mergedSettings = array_merge($settings, $route->getMergeableData());
// Add ExceptionHandler
if (count($route->getExceptionHandlers())) {
$this->exceptionHandlers = array_merge($this->exceptionHandlers, $route->getExceptionHandlers());
}
}
}
}
@@ -384,15 +384,9 @@ class RouterBase {
$parent = $route->getParent();
if($parent !== null && ($parent instanceof RouterGroup) && $parent->getDomain() !== null) {
if(is_array($parent->getDomain())) {
$domains = $parent->getDomain();
$domain = array_shift($domains);
} else {
$domain = $parent->getDomain();
}
$domain = '//' . $domain;
if($parent !== null && $parent instanceof RouterGroup && count($parent->getDomains())) {
$domain = $parent->getDomains();
$domain = '//' . $domain[0];
}
$url = $domain . '/' . trim($route->getUrl(), '/');