I am new to Zend Framework. I began to study it during a project that I am still working on at school. I got a little stuck on how to deal with ACLs in conjunction with my modular structure (which I really like), and researching the Internet doesn't seem to give me the information I need. Probably because I am not very structured yet, but I still thought I would ask here. Thanks in advance!
At the moment, following most of the best practices that I have researched, I have created a modular structure, for example:
application/ modules/ admin/ default/
I use the plugin to manage my ACL, for example (for simplicity / readability, I added only a part):
$acl = new Zend_Acl(); $acl->addRole(new Zend_Acl_Role('guest')) ->addRole(new Zend_Acl_Role('member'), 'guest'); ->addRole(new Zend_Acl_Role('admin'), 'member'); $acl->addResource(new Zend_Acl_Resource('index')); ->addResource(new Zend_Acl_Resource('admin:index')); $acl->allow('guest', 'index', array('index')); ->allow('member', 'index', array('userpanel')); ->allow('admin');
In any case, the ACL works fine in the default module - even in the admin module, but the problem occurs when I have identical controller names and actions, for example:
This action will allow users to edit their own account Module: Default Controller: User Action: Edit This action will allow an admin to edit any account Module: Admin Controller: User Action: Edit
When I set the rule in the ACL as follows:
$acl->allow('member', 'user', array('edit'));
The user will also be allowed access to the admin edit page on the user controller. How to tell ACL what is the difference between modules? I saw that in many examples, to add resources to the ACL, "admin: user" was used instead of "user" as the name of the controller / resource. This does not seem to work if the names of the controllers and / or actions are identical.
So, the big question is: how do I solve this problem in my current situation or how do you suggest me to structure my application in order to avoid the problem together? I would prefer not to resort to using additional control prefixes, such as "Admin_AdminUserController", or simply remove all modules and just do "adminEditAction", etc.