Archived
1
0
Fork 0

app/listeners/AccessListener.php: implement modules.

This commit is contained in:
Henrik Hautakoski 2018-10-10 00:19:58 +02:00
parent e5b0e1fcfd
commit c94c0fed7b
No known key found for this signature in database
GPG key ID: 839F3A7EAFAEAFAA

View file

@ -34,8 +34,7 @@ class AccessListener extends Plugin
$role = Acl::ROLE_GUEST;
}
// Get the resource from controller name.
$resource = $dispatcher->getControllerName();
$resource = $this->_getCurrentResource($dispatcher);
// Ignore checks for error resource.
if (in_array($resource, $this->_ignored_resources)) {
@ -70,4 +69,15 @@ class AccessListener extends Plugin
}
return true;
}
protected function _getCurrentResource($dispatcher)
{
// If default module, only fetch controller name.
if (strlen($dispatcher->getModuleName()) < 1) {
return $dispatcher->getControllerName();
}
// Otherwise, we follow the syntax "<module>/<controller>"
return "{$dispatcher->getModuleName()}/{$dispatcher->getControllerName()}";
}
}