Returns the user roles

@return array The roles
19784
public function getRoles()
    {
        $roles = $this->roles;

        foreach ($this->getGroups() as $group) {
            $roles = array_merge($roles, $group->getRoles());
        }

        $newRoles = [];

        if ($this->getActiveRole()) {
            $newRoles = $this->getActiveRole()->getRoles();
        }

        $finalRoles = array_merge($roles, $newRoles);

        // we need to make sure to have at least one role
        $finalRoles[] = static::ROLE_DEFAULT;

        return array_unique($finalRoles);
    }
1069773
function roles()
    {
        $groups = $this->attribute( 'groups' );
        $groups[] = $this->attribute( 'contentobject_id' );
        return eZRole::fetchByUser( $groups );
    }
1372584
public function getPermissions()
    {
        $permissions = [[], []];

        foreach ($this->roles as $role) {
            $permissions[] = $role->getPermissions();
        }

        return call_user_func_array('array_merge', $permissions);
    }
1187601
public function getImpersonatingUser()
    {
        if ($this->isGranted('ROLE_PREVIOUS_ADMIN')) {
            foreach ($this->tokenStorage->getToken()->getRoles() as $role) {
                if ($role instanceof SwitchUserRole) {
                    return $role->getSource()->getUser();
                }
            }
        }
    }
57467
public function getRoles()
    {
        if (is_array($this->_roles)) {
            return $this->_roles;
        }
        if (!$this->id) {
            return $this->_roles = [];
        }
        return $this->_roles = \Cms\Orm\CmsAuthRoleQuery::joinedRoleByAuthId($this->id)
            ->orderAsc('name', 'cms_role')
            ->findPairs('cms_role_id', 'cms_role.name');
    }
664581
protected function getListUserRole()
    {
        $conditions = $this->query_filter;
        $conditions['limit'] = $this->data_limit;

        $list = (array) $this->role->getList($conditions);
        $this->prepareListUserRole($list);

        return $list;
    }
467425
public function getRoles(): ?array
    {
        $roles = $this->roles;
        $groupRoles = [[]];

        foreach ($this->getGroups() as $group) {
            $groupRoles[] = $group->getRoles();
        }
        $groupRoles = array_merge(...$groupRoles);

        return array_unique(array_merge($roles, $groupRoles));
    }
24449
def user_roles(self):
        
        # We do here some lazy loading.
        if not self._user_roles:
            self._user_roles = UserRoleManager(self)
        return self._user_roles
385405
def get_user_roles(self, user):
        
        return self.service.get_user_roles(
            user, self.url_prefix, self.auth, self.session, self.session_send_opts)
1084309
public function getRoles() {

		$roles = [];

		foreach($this -> permissions as $role => $permissions) {
			$roles[$role] = $this -> getRole($role);
		}

		return $roles;
	}
853673
protected function getUserRoles(): Collection
    {
        if (! \is_null($this->userRoles)) {
            return $this->userRoles;
        } elseif (! $this->auth->guest()) {
            return $this->auth->roles();
        }

        return new Collection($this->roles->has('guest') ? ['guest'] : []);
    }
763510
protected function _roles()
    {
        $this->loadModel('CakeManager.Roles');

        $list = $this->Roles->find('list')->toArray();

        if (empty($list)) {
            $this->out('No roles found.');
        }

        // Creating administrators
        if (!in_array('Administrators', $list)) {
            $data = [
                'name' => 'Administrators',
                'login_redirect' => '/admin/manager/pages/dashboard',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Administrators" created');
            } else {
                $this->out('Role "Administrators" could not be created');
                return false;
            }
        }

        // Creating moderators
        if (!in_array('Moderators', $list)) {
            $data = [
                'name' => 'Moderators',
                'login_redirect' => '/',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Moderators" created');
            } else {
                $this->out('Role "Moderators" could not be created');
                return false;
            }
        }

        // Creating Users
        if (!in_array('Users', $list)) {
            $data = [
                'name' => 'Users',
                'login_redirect' => '/',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Users" created');
            } else {
                $this->out('Role "Users" could not be created');
                return false;
            }
        }

        // Creating unregisterd
        if (!in_array('Users', $list)) {
            $data = [
                'name' => 'Unregistered',
                'login_redirect' => '/',
            ];

            $new = $this->Roles->newEntity($data);
            if ($this->Roles->save($new)) {
                $this->out('Role "Unregistered" created');
            } else {
                $this->out('Role "Unregistered" could not be created');
                return false;
            }
        }

        $this->out("Done.");
        return true;
    }
907989
public function getRolesForUserCreation(): array
    {
        $roles = [];

        if (auth()->check()) {
            /** @var HCUser $user */
            $user = auth()->user();

            if ($user->isSuperAdmin()) {
                $roles = HCAclRole::select('id', 'name as label')->orderBy('name')->get()->toArray();
            } else {
                foreach ($user->roles as $role) {
                    $roles[] = [
                        'id' => $role->id,
                        'label' => $role->name,
                    ];
                }
            }
        }

        return $roles;
    }
612030
public function getRolesForUserCreation()
    {
        $rolesList = [];

        // logged user
        $user = auth()->user();

        if( auth()->check() ) {
            if( $user->isSuperAdmin() ) {
                $rolesList = Roles::select('id', 'name as label')->orderBy('name')->get();
            } else {
                foreach ( $user->roles as $role ) {
                    $rolesList[] = [
                        'id'    => $role->id,
                        'label' => $role->name,
                    ];
                }
            }
        }

        return $rolesList;
    }
1110337
protected function getUserRoles()
	{
		if ($this->session_machine === null) {
			throw new RuntimeException('Session machine not ready ‒ '.__METHOD__.' called too soon.');
		}

		if ($this->session_machine->state == '') {
			return null;
		} else {
			return (array) $this->session_machine[$this->user_roles_property];
		}
	}
539310
public function roles()
    {
        $roles = $this->morphToMany(
            Config::get('laratrust.models.role'),
            'user',
            Config::get('laratrust.tables.role_user'),
            Config::get('laratrust.foreign_keys.user'),
            Config::get('laratrust.foreign_keys.role')
        );

        if (Config::get('laratrust.use_teams')) {
            $roles->withPivot(Config::get('laratrust.foreign_keys.team'));
        }

        return $roles;
    }
338651
public function getRoles($user_id) {
        $results = $this->find('all', array(
            'conditions' => array(
                'RequestObject.foreign_key' => $user_id,
                'RequestObject.model' => USER_MODEL
            )
        ));

        if ($results) {
            // Grab the direct parents (or roles)
            $results = $this->find('all', array(
                'conditions' => array('RequestObject.id' => Hash::extract($results, '{n}.RequestObject.parent_id'))
            ));

            // Also grab the children of the parents since the user has access to them as well
            $results = array_merge($results, $this->find('all', array(
                'conditions' => array(
                    'RequestObject.parent_id' => Hash::extract($results, '{n}.RequestObject.id'),
                    'RequestObject.model' => null,
                    'RequestObject.foreign_key' => null
                )
            )));
        }

        return $results;
    }