Zend 的 Acl 只允许在控制器中创建资源
但是,控制器可能位于任何模块上,而不仅仅是默认模块。所以,我从互联网上阅读了一些文章,我找到了一篇并尝试了这个:
$acl -> addResource(new Zend_Acl_Resource("admin"));
$acl -> addResource(new Zend_Acl_Resource("admin:page"), "admin");
$acl -> addResource(new Zend_Acl_Resource("admin:posts"), "admin");
但是,当我浏览到相应的页面时,仍然会收到有关page
未找到或未posts
找到资源的错误。
如何设置模块特定的 ACL 资源?
更新:
$acl -> addrole(new Zend_Acl_Role('guest'))
-> addrole(new Zend_Acl_ROle('admin'), 'admin');
$acl -> addResource(new Zend_Acl_Resource("page")); //controller with same name in admin module exists
$acl -> addResource(new Zend_Acl_Resource("admin"));
$acl -> addResource(new Zend_Acl_Resource("admin:page"), "admin");
$acl -> addResource(new Zend_Acl_Resource("admin:posts"), "admin");
$acl -> deny(null, null);
$acl -> allow('user', 'page', 'view');
$acl -> allow('admin', null);