/** * @return array */ public function getRoles() { $rolesEntities = $this->roles->toArray(); $roles = []; foreach ($rolesEntities as $role) { $roles[$role->getId()] = $role->getName(); } return $roles; }
/** * {@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)); }
/** * @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'])); }
/** * 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(); }
/** * @return Role[] */ public function getAuthorizedRoles() { return $this->authorizedRoles->toArray(); }