mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
[BUGFIX] Group will now always be rendered no matter of what prefix is.
This commit is contained in:
@@ -12,28 +12,21 @@ class RouterGroup extends RouterEntry {
|
|||||||
|
|
||||||
public function renderRoute(Request $request) {
|
public function renderRoute(Request $request) {
|
||||||
// Check if request method is allowed
|
// Check if request method is allowed
|
||||||
|
$hasAccess = (!$this->method);
|
||||||
|
|
||||||
if(trim($this->prefix) === '' || strtolower($request->getUri()) == strtolower($this->prefix) || stripos($request->getUri(), $this->prefix) === 0) {
|
if($this->method) {
|
||||||
|
if(is_array($this->method)) {
|
||||||
$hasAccess = (!$this->method);
|
$hasAccess = (in_array($request->getMethod(), $this->getRequestMethods()));
|
||||||
|
} else {
|
||||||
if($this->method) {
|
$hasAccess = strtolower($this->getRequestMethods()) == strtolower($request->getMethod());
|
||||||
if(is_array($this->method)) {
|
|
||||||
$hasAccess = (in_array($request->getMethod(), $this->getRequestMethods()));
|
|
||||||
} else {
|
|
||||||
$hasAccess = strtolower($this->getRequestMethods()) == strtolower($request->getMethod());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$hasAccess) {
|
|
||||||
throw new RouterException('Method not allowed');
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::renderRoute($request);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No match here, move on...
|
if(!$hasAccess) {
|
||||||
return null;
|
throw new RouterException('Method not allowed');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::renderRoute($request);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function matchRoute(Request $request) {
|
public function matchRoute(Request $request) {
|
||||||
|
|||||||
Reference in New Issue
Block a user