Fixed RoleHierarchy class to return an array of strings instead of array of objects

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI (W00d5t0ck) 2012-09-01 18:00:19 +02:00
parent 8bee5a4217
commit bf41a6f92f

View File

@ -4,6 +4,7 @@ namespace KekRozsak\SecurityBundle\Service;
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
use Symfony\Bridge\Doctrine\RegistryInterface;
use Symfony\Component\Security\Core\Role\RoleInterface;
class RoleHierarchy implements RoleHierarchyInterface
{
@ -23,13 +24,19 @@ class RoleHierarchy implements RoleHierarchyInterface
{
$reachableRoles = array();
foreach ($roles as $role) {
if (!isset($this->map[$role->getRole()])) {
if ($role instanceof RoleInterface) {
$thisRole = $role->getRole();
} else {
$thisRole = $role;
}
if (!isset($this->map[$thisRole])) {
continue;
}
$reachableRoles[] = $thisRole;
foreach ($this->map[$role->getRole()] as $r) {
foreach ($this->map[$thisRole] as $r) {
if (($childRole = $this->roleRepo->findOneByName($r)) !== null) {
$reachableRoles[] = $childRole;
$reachableRoles[] = $childRole->getRole();
}
}
}