我有 application\plugins\Acl.php 与:
class Application_Plugin_Acl extends Zend_Controller_Plugin_Abstract {
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
$acl = new Zend_Acl();
我在那里添加角色。我也有助手 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);
而且我无法从视图文件中访问角色:
$this->hasAccess('user', 'partner', 'news')