예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function isGranted($permissionCode)
 {
     $identity = $this->currentIdentityProvider->getIdentity();
     if (null === $identity) {
         $identity = new \Sylius\Component\Rbac\Model\AnonymousIdentity();
     }
     if (!$identity instanceof IdentityInterface) {
         throw new \InvalidArgumentException('Current identity must implement "Sylius\\Component\\Rbac\\Model\\IdentityInterface".');
     }
     $roles = $this->rolesResolver->getRoles($identity);
     foreach ($roles as $role) {
         if ($this->permissionMap->hasPermission($role, $permissionCode)) {
             return true;
         }
     }
     return false;
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function getPermissions(RoleInterface $role)
 {
     return $this->map->getPermissions($role);
 }