mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-07-11 23:12:11 +00:00
[FEATURE] Added support for domains array on group.
- Group will not render if one or more domain does not match.
This commit is contained in:
@@ -13,12 +13,33 @@ class RouterGroup extends RouterEntry {
|
|||||||
protected function matchDomain() {
|
protected function matchDomain() {
|
||||||
if($this->domain !== null) {
|
if($this->domain !== null) {
|
||||||
|
|
||||||
$parameters = $this->parseParameters($this->domain, request()->getHost(), '[^.]*');
|
if(is_array($this->domain)) {
|
||||||
|
|
||||||
|
$max = count($this->domain);
|
||||||
|
|
||||||
|
for($i = 0; $i < $max; $i++) {
|
||||||
|
$domain = $this->domain[$i];
|
||||||
|
|
||||||
|
$parameters = $this->parseParameters($domain, request()->getHost(), '[^.]*');
|
||||||
|
|
||||||
if($parameters !== null) {
|
if($parameters !== null) {
|
||||||
$this->parameters = $parameters;
|
$this->parameters = $parameters;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
$parameters = $this->parseParameters($this->domain, request()->getHost(), '[^.]*');
|
||||||
|
|
||||||
|
if ($parameters !== null) {
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function renderRoute(Request $request) {
|
public function renderRoute(Request $request) {
|
||||||
@@ -37,7 +58,9 @@ class RouterGroup extends RouterEntry {
|
|||||||
throw new RouterException('Method not allowed');
|
throw new RouterException('Method not allowed');
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->matchDomain();
|
if($this->matchDomain() === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return parent::renderRoute($request);
|
return parent::renderRoute($request);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user