I created a MVC with Zend by reading http://framework.zend.com/manual/en/zend.controller.modular.html.
The problem is that I can't find a way to use Zend_ACL with modular structure. Zend_Acl simply does not have a method to add modules. It only allows me to add controller and action.
How do I use Zend_Acl with modular structrue? Is it even possible with current version of Zend Framework?
It absolutely is. That's what we do in our project. We authenticate URI paths ($request->getPathInfo()
), like: /admin/user/edit
. Here "admin" is a module, "user" is a controller, and "edit" is an action. And we have an access plugin:
class Our_Application_Plugin_Access extends Zend_Controller_Plugin_Abstract {
public function preDispatch(Zend_Controller_Request_Abstract $request) {
foreach (self::current_roles() as $role) {
if (
Zend_Registry::get('bootstrap')->siteacl->isAllowed(
$role,
$request->getPathInfo()
)
) return;
}
$this->not_allowed($request);
}
...
}
Registered in application.ini:
resources.frontController.plugins.access = "Our_Application_Plugin_Access"