Exemple #1
0
 /**
  * @return array
  */
 public function getRoles()
 {
     $rolesEntities = $this->roles->toArray();
     $roles = [];
     foreach ($rolesEntities as $role) {
         $roles[$role->getId()] = $role->getName();
     }
     return $roles;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     $roles = $this->roles->toArray();
     /** @var Group $group */
     foreach ($this->groups as $group) {
         $roles = array_merge($roles, $group->getRoles());
     }
     return array_values(array_unique($roles));
 }
Exemple #3
0
 /**
  * @return Role[]
  *
  * @note Every user must *at least* have ROLE_USER as a role
  */
 public function getRoles()
 {
     return array_unique(array_merge($this->roles->toArray(), ['ROLE_USER']));
 }
Exemple #4
0
 /**
  * Returns the user's roles as an array of entities. The roles
  * owned by groups the user is a member are included by default.
  *
  * @param bool $areGroupsIncluded
  *
  * @return array[Role]
  */
 public function getEntityRoles($areGroupsIncluded = true)
 {
     $roles = array();
     if ($this->roles) {
         $roles = $this->roles->toArray();
     }
     if ($areGroupsIncluded) {
         foreach ($this->getGroups() as $group) {
             foreach ($group->getEntityRoles() as $role) {
                 if (!in_array($role, $roles)) {
                     $roles[] = $role;
                 }
             }
         }
     }
     return $roles;
 }
 /**
  * @return Role[]
  */
 public function getRoles()
 {
     return $this->roles->toArray();
 }
Exemple #6
0
 /**
  * @return Role[]
  */
 public function getAuthorizedRoles()
 {
     return $this->authorizedRoles->toArray();
 }