Search code examples
zend-frameworkzend-acl

Zend Framework: Implement Zend_Acl_Resources


how should i implement Zend_Acl_Resources? do i have something like:

$acl->isAllowed()

in controller actions? i somehow think there maybe a better way ... but cant think of it.


Solution

  • You can set this in preDispatch in plugin or in preDispatch of Controller base class. There you have your request and you can check sth like this:

    if($acl->isAllowed('resource'.$request->getControllerName().$request->getActionName())){
        return;
    } else {
       //redirect to 403
    } 
    

    You can also extend resourceControllerAction from resourceController to ensure the rights are always inherited. And that way you can simplify the ACL rules generation...