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:
parent
8bee5a4217
commit
bf41a6f92f
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user