- Added support for setups where getallheaders function is not availible.
- Made matchDomain method in RouterGroup always return boolean.
This commit is contained in:
Simon Sessingø
2015-12-19 20:15:10 +01:00
parent 3510c4c5a4
commit df2545dd37
3 changed files with 24 additions and 11 deletions
+11 -1
View File
@@ -27,7 +27,17 @@ class Request {
$this->host = $_SERVER['HTTP_HOST']; $this->host = $_SERVER['HTTP_HOST'];
$this->uri = $_SERVER['REQUEST_URI']; $this->uri = $_SERVER['REQUEST_URI'];
$this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : strtolower($_SERVER['REQUEST_METHOD']); $this->method = (isset($_POST['_method'])) ? strtolower($_POST['_method']) : strtolower($_SERVER['REQUEST_METHOD']);
$this->headers = array_change_key_case(getallheaders(), CASE_LOWER); $this->headers = $this->getAllHeaders();
}
public function getAllHeaders() {
$headers = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) === 'HTTP_') {
$headers[str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($name, 5))))] = $value;
}
}
return $headers;
} }
public function getIsSecure() { public function getIsSecure() {
+9 -6
View File
@@ -54,7 +54,10 @@ class RouterBase {
$route = $routes[$i]; $route = $routes[$i];
$route->addSettings($settings); $route->addSettings($settings);
if($backStack) {
$route->setGroup($group); $route->setGroup($group);
}
if($this->defaultNamespace && !$route->getNamespace()) { if($this->defaultNamespace && !$route->getNamespace()) {
$namespace = null; $namespace = null;
@@ -124,6 +127,12 @@ class RouterBase {
$route = $this->controllerUrlMap[$i]; $route = $this->controllerUrlMap[$i];
if($route->getGroup() !== null) {
if($route->getGroup()->matchDomain($this->request) === false) {
continue;
}
}
$routeMatch = $route->matchRoute($this->request); $routeMatch = $route->matchRoute($this->request);
if($routeMatch) { if($routeMatch) {
@@ -133,12 +142,6 @@ class RouterBase {
continue; continue;
} }
if($route->getGroup() !== null) {
if($route->getGroup()->matchDomain($this->request) === null) {
continue;
}
}
$routeNotAllowed = false; $routeNotAllowed = false;
$this->loadedRoute = $route; $this->loadedRoute = $route;
+3 -3
View File
@@ -28,7 +28,7 @@ class RouterGroup extends RouterEntry {
} }
} }
return null; return false;
} }
$parameters = $this->parseParameters($this->domain, $request->getHost(), '[^.]*'); $parameters = $this->parseParameters($this->domain, $request->getHost(), '[^.]*');
@@ -38,10 +38,10 @@ class RouterGroup extends RouterEntry {
return true; return true;
} }
return null; return false;
} }
return false; return true;
} }
public function renderRoute(Request $request) { public function renderRoute(Request $request) {