mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 00:37:52 +00:00
Merge pull request #29 from skipperbent/development
[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) {
|
||||
// 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) {
|
||||
|
||||
$hasAccess = (!$this->method);
|
||||
|
||||
if($this->method) {
|
||||
if(is_array($this->method)) {
|
||||
$hasAccess = (in_array($request->getMethod(), $this->getRequestMethods()));
|
||||
} else {
|
||||
$hasAccess = strtolower($this->getRequestMethods()) == strtolower($request->getMethod());
|
||||
}
|
||||
if($this->method) {
|
||||
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...
|
||||
return null;
|
||||
if(!$hasAccess) {
|
||||
throw new RouterException('Method not allowed');
|
||||
}
|
||||
|
||||
return parent::renderRoute($request);
|
||||
}
|
||||
|
||||
public function matchRoute(Request $request) {
|
||||
|
||||
Reference in New Issue
Block a user