From bf41a6f92f829f780ccfba08e425257c0b9059ff Mon Sep 17 00:00:00 2001 From: "Gergely POLONKAI (W00d5t0ck)" Date: Sat, 1 Sep 2012 18:00:19 +0200 Subject: [PATCH] Fixed RoleHierarchy class to return an array of strings instead of array of objects Signed-off-by: Gergely POLONKAI (W00d5t0ck) --- .../SecurityBundle/Service/RoleHierarchy.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/KekRozsak/SecurityBundle/Service/RoleHierarchy.php b/src/KekRozsak/SecurityBundle/Service/RoleHierarchy.php index 9fe5231..7fcfcbf 100644 --- a/src/KekRozsak/SecurityBundle/Service/RoleHierarchy.php +++ b/src/KekRozsak/SecurityBundle/Service/RoleHierarchy.php @@ -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(); } } }