Reverted previous RoleHierarchy change
The previous attempt made plain security.context->isGranted() fail. Extending Symfony's Role object makes everything fine, although the solution is more than ugly. Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
parent
f6acfae76d
commit
17bf54b4d6
@ -4,6 +4,7 @@ namespace KekRozsak\SecurityBundle\Entity;
|
|||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Security\Core\Role\RoleInterface;
|
use Symfony\Component\Security\Core\Role\RoleInterface;
|
||||||
|
use Symfony\Component\Security\Core\Role\Role as SymfonyRole;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* KekRozsak\SecurityBundle\Entity\Role
|
* KekRozsak\SecurityBundle\Entity\Role
|
||||||
@ -11,7 +12,7 @@ use Symfony\Component\Security\Core\Role\RoleInterface;
|
|||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="roles")
|
* @ORM\Table(name="roles")
|
||||||
*/
|
*/
|
||||||
class Role implements RoleInterface
|
class Role extends SymfonyRole implements RoleInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The ID of the Role
|
* The ID of the Role
|
||||||
|
@ -24,19 +24,15 @@ class RoleHierarchy implements RoleHierarchyInterface
|
|||||||
{
|
{
|
||||||
$reachableRoles = array();
|
$reachableRoles = array();
|
||||||
foreach ($roles as $role) {
|
foreach ($roles as $role) {
|
||||||
if ($role instanceof RoleInterface) {
|
$thisRole = $role->getRole();
|
||||||
$thisRole = $role->getRole();
|
|
||||||
} else {
|
|
||||||
$thisRole = $role;
|
|
||||||
}
|
|
||||||
if (!isset($this->map[$thisRole])) {
|
if (!isset($this->map[$thisRole])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$reachableRoles[] = $thisRole;
|
$reachableRoles[] = $role;
|
||||||
|
|
||||||
foreach ($this->map[$thisRole] as $r) {
|
foreach ($this->map[$thisRole] as $r) {
|
||||||
if (($childRole = $this->roleRepo->findOneByName($r)) !== null) {
|
if (($childRole = $this->roleRepo->findOneByName($r)) !== null) {
|
||||||
$reachableRoles[] = $childRole->getRole();
|
$reachableRoles[] = $childRole;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user