Пример #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);
 }