如何设置模块特定的ACL资源?
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
not found 或 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);
Zend's Acl allows the resource to be created in controller only
But, the controllers might be on any module not just only the default module. So, I read some article off the internet, I found one and tried this:
$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");
But, still, when i browse to the respective pages, I get errors regarding resouce page
not found, or posts
not found.
How to setup Module Specific ACL Resource?
Update:
$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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜您发布的代码是某种伪代码,因为它无效。尽管如此,这个答案应该可以完美地工作。
I'm guessing the code you posted was some sort of pseudo code, as it wasn't valid. Still, this answer should work perfectly fine as is.