Issues

ZF-5638: Add methods to get defined roles, ressources, rules

Issue Type: Community Driven Feature Created: 2009-01-27T06:01:52.000+0000 Last Updated: 2009-09-19T04:52:38.000+0000 Status: Resolved Fix version(s): - 1.9.3 (22/Sep/09)

Reporter: Nico Edtinger (nico) Assignee: Sudheer Satyanarayana (bonaparte) Tags: - Zend_Acl

Related issues: - ZF-1356

Attachments: - acl-get-roles-patch.tar.gz

Description

I haven't found a method to get the defined roles (or ressources or rules for that matter). The use case I need it for is quite simple.

Very early in the request we setup a Zend_Acl instance with some roles, predefined ressources and rules. We also have a database with users and their assigned ACL role. Now what we want to do is creating a simple form with all the defined roles, so one of them can be assigned to a specific user.

But all roles defined earlier are hidden in the protected variable _roles and having to store them in an extra variable, just to be able to use them in one form, doesn't seem to be right.

At least for roles it should be quite easy to add a method like this to Zend_Acl_Role_Registry: public function getRoles() { return array_keys($this->_roles); }

As ressources and rules seems to be hidden too, there also should be an easy way to access them.

Comments

Posted by James Green (jgreen_so) on 2009-02-17T09:06:11.000+0000

Just hit upon this very matter myself. Clearly it would be trivial to implement as an extended class, butshould this feature be included within Zend_Acl for shipping?

Posted by James Green (jgreen_so) on 2009-02-17T09:31:38.000+0000

To do this Zend_Acl_Role_Registry requires a new method:

public function getRoles() { return $this->_roles; }

Then Zend_Acl requires a new method:

public function getRegisteredRoles() { return $this->_getRoleRegistry()->getRoles(); }

You may then iterate over the list returned by Zend_Acl::getRegisteredRoles(). The keys will be the role ID.

Posted by Ralph Schindler (ralph) on 2009-09-10T08:49:32.000+0000

While this is a worthwhile feature, the ZF team will not develop this feature, but if a community member would like to pick up and develop it, they may make an assignment of it.

Posted by Sudheer Satyanarayana (bonaparte) on 2009-09-18T09:02:18.000+0000

Like the other commenter said, it appears trivial to add getRegisteredRoles() method. I have added the methods in Acl.php and Acl_Role_Registry.php with unit test method.

Posted by Matthew Weier O'Phinney (matthew) on 2009-09-18T13:05:38.000+0000

Patch applied; allowing to add to 1.9 release branch as well.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts