Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.

Fixed failure when implementing custom rbac roles#4210

Closed
tux-rampage wants to merge 3 commits intozendframework:masterfrom
tux-rampage:rbac-issue
Closed

Fixed failure when implementing custom rbac roles#4210
tux-rampage wants to merge 3 commits intozendframework:masterfrom
tux-rampage:rbac-issue

Conversation

@tux-rampage
Copy link
Copy Markdown
Contributor

Zend\Permissions\Rbac\Rbac::isGranted() will faill, when implementing the interface Zend\Permissions\Rbac\RoleInterface with a custom role and adding it to a Zend\Permissions\Rbac\Rbac instance with parents (due to missing implementation of RecursiveIterator on the custom role).

$custom = new MyCustomRole();
$rbac->addRole($custom, 'foo');
$rbac->isGranted('foo', 'something'); // <- failure

This example will throw an UnexpectedValueException ("Objects returned by RecursiveIterator::getChildren() must implement RecursiveIterator").

  • Added a unit test to reflect this behavior
  • Implemented a fix by improving the hasChildren() implementation in
    Zend\Permissions\Rbac\AbstractIterator

When adding custom roles which implement
Zend\Permissions\Rbac\RoleInterface, an UnexpectedValueException is
thrown due to missing RecursiveIterator implementation.

Fixed this exception by improving the hasChildren() implementation in
Zend\Permissions\Rbac\AbstractIterator
@danizord
Copy link
Copy Markdown
Contributor

👍

Removed the leading slash from interface name string passed to
getMockForAbstractClass().
The @return annotation for Zend\Permissions\Rbac\Rbac::addRole() is
incorrect. This method returns $this and not the rule instance.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be simply self.

@ghost ghost assigned weierophinney Apr 12, 2013
weierophinney added a commit that referenced this pull request Apr 12, 2013
Fixed failure when implementing custom rbac roles
weierophinney added a commit that referenced this pull request Apr 12, 2013
- docblock can simply refer to "self"
weierophinney added a commit that referenced this pull request Apr 12, 2013
weierophinney added a commit to zendframework/zend-permissions-rbac that referenced this pull request May 15, 2015
…rbac-issue

Fixed failure when implementing custom rbac roles
weierophinney added a commit to zendframework/zend-permissions-rbac that referenced this pull request May 15, 2015
- docblock can simply refer to "self"
weierophinney added a commit to zendframework/zend-permissions-rbac that referenced this pull request May 15, 2015
weierophinney added a commit to zendframework/zend-permissions-rbac that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants