Issues

ZF-10744: Zend_Acl->getRoles() does not properly documented or implemented

Issue Type: Bug Created: 2010-11-25T08:06:23.000+0000 Last Updated: 2010-12-17T04:33:10.000+0000 Status: Resolved Fix version(s): - 1.11.2 (30/Dec/10)

Reporter: Sergey Gruzdev (potam) Assignee: Andries Seutens (andries) Tags: - Zend_Acl

Related issues: Attachments:

Description

I'm not quite sure, is this documentation or code issue. Taking in mind Zend_Acl->getRoles() method doc, i expected roles instances:

source:

/**
 * @return array of registered roles
 */
public function getRoles()
{
    return array_keys($this->_getRoleRegistry()->getRoles());
}

So, the implementation can not return role instances, just IDs. I think this should be documented unequivocally or corrected in case if instances have been mentioned.

And IMHO: On the one hand current behavior is reasonable, but in case if custom roles implementation is necessary, Zend_Acl can not be used as unique roles registry. It is not a catastrophe, but not so comfortably as well.

Comments

Posted by Andries Seutens (andries) on 2010-12-17T03:30:52.000+0000

This is expected, as there is a unittest in place that verifies this behaviour.

If you want access to the role instances, you could simply subclass Zend_Acl:

<pre class="highlight">
class My_Acl extends Zend_Acl
{
    public function getRoles()
    {
        return $this->_getRoleRegistry()->getRoles();
    }
}

Unless you have any objections, this issue can be closed.

Posted by Sergey Gruzdev (potam) on 2010-12-17T03:46:44.000+0000

I have no objections, thanks for answer. May be there's meaning to change method doc for prevent misunderstanding.

Posted by Andries Seutens (andries) on 2010-12-17T04:31:41.000+0000

Fixed in svn r23529 and merged to 1.11 release branch in svn r23530

Posted by Andries Seutens (andries) on 2010-12-17T04:33:10.000+0000

RE: previous comment

I've improved the docblock for the getRoles() method, so that it's clear that only role ID's are returned.

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