Skip to content

Commit

Permalink
Rbac::getRole() : check if required role is an object before loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmleroux committed Mar 20, 2014
1 parent 39a1eb9 commit ae35ff1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/Zend/Permissions/Rbac/Rbac.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,16 @@ public function getRole($objectOrName)
);
}

if (is_object($objectOrName)) {
$requiredRole = $objectOrName->getName();
} else {
$requiredRole = $objectOrName;
}

$it = new RecursiveIteratorIterator($this, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($it as $leaf) {
/** @var RoleInterface $leaf */
if ((is_string($objectOrName) && $leaf->getName() == $objectOrName)
|| (is_object($objectOrName) && $leaf->getName() == $objectOrName->getName())
) {
if ($leaf->getName() == $requiredRole) {
return $leaf;
}
}
Expand Down

0 comments on commit ae35ff1

Please sign in to comment.