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:
Gergely POLONKAI (W00d5t0ck) 2012-09-01 23:12:15 +02:00
parent f6acfae76d
commit 17bf54b4d6
2 changed files with 5 additions and 8 deletions

View File

@ -4,6 +4,7 @@ namespace KekRozsak\SecurityBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\Role\RoleInterface;
use Symfony\Component\Security\Core\Role\Role as SymfonyRole;
/**
* KekRozsak\SecurityBundle\Entity\Role
@ -11,7 +12,7 @@ use Symfony\Component\Security\Core\Role\RoleInterface;
* @ORM\Entity
* @ORM\Table(name="roles")
*/
class Role implements RoleInterface
class Role extends SymfonyRole implements RoleInterface
{
/**
* The ID of the Role

View File

@ -24,19 +24,15 @@ class RoleHierarchy implements RoleHierarchyInterface
{
$reachableRoles = array();
foreach ($roles as $role) {
if ($role instanceof RoleInterface) {
$thisRole = $role->getRole();
} else {
$thisRole = $role;
}
if (!isset($this->map[$thisRole])) {
continue;
}
$reachableRoles[] = $thisRole;
$reachableRoles[] = $role;
foreach ($this->map[$thisRole] as $r) {
if (($childRole = $this->roleRepo->findOneByName($r)) !== null) {
$reachableRoles[] = $childRole->getRole();
$reachableRoles[] = $childRole;
}
}
}