getRoles() public method

Get roles.
public getRoles ( ) : Doctrine\Common\Collections\Collection
return Doctrine\Common\Collections\Collection
Exemplo n.º 1
0
 /**
  * Adds the given role to the group.
  *
  * @param Group $group
  * @param array $roleData
  *
  * @return bool
  *
  * @throws \Sulu\Component\Rest\Exception\EntityNotFoundException
  */
 private function addRole(Group $group, $roleData)
 {
     if (isset($roleData['id'])) {
         $role = $this->get('sulu.repository.role')->findRoleById($roleData['id']);
         if (!$role) {
             throw new EntityNotFoundException($this->get('sulu.repository.role')->getClassName(), $roleData['id']);
         }
         if (!$group->getRoles()->contains($role)) {
             $group->addRole($role);
         }
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Checks if the given group has the permission to execute the desired task.
  *
  * @param SecurityCondition $object
  * @param int               $attribute
  * @param Group             $group
  * @param array             $locales
  *
  * @return bool
  */
 public function checkUserGroup($object, $attribute, Group $group, $locales)
 {
     // check if the group contains the permission
     foreach ($group->getRoles() as $role) {
         /** @var RoleInterface $role */
         if ($this->checkPermissions($object, $attribute, $role->getPermissions(), $locales)) {
             return true;
         }
     }
     // check if one of the child group contains the permission
     $children = $group->getChildren();
     if (!empty($children)) {
         foreach ($children as $child) {
             if ($this->checkUserGroup($object, $attribute, $child, $locales)) {
                 return true;
             }
         }
     }
     return false;
 }