I have application\plugins\Acl.php with:
class Application_Plugin_Acl extends Zend_Controller_Plugin_Abstract {
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
$acl = new Zend_Acl();
and I add roles there. I also have heleper HasAccess.php:
class Zend_View_Helper_HasAccess extends Zend_View_Helper_Abstract {
public function hasAccess($role, $action, $controller) {
if (!$this->_acl) {
$acl = Zend_Controller_Front::getInstance()->getPlugin('Application_Plugin_Acl');
}
return $acl->isAllowed($role, $controller, $action);
and I cannot access roles from view files:
$this->hasAccess('user', 'partner', 'news')
in application\plugins\Acl.php you have to attach that ACL instance to your views
Than, you can use ACL in view files:
if you want to use ACL in View Helpers, use: