Get the list of roles of a user

@return string[]
174829
public function getIdentityRoles(UserInterface $user = null)
    {
        if ($user === null) {
            $user = $this->getDefaultIdentity();
            if (!$user) {
                return (array) $this->getModuleOptions()->getDefaultGuestRole();
            }
        }

        $resultSet = $this->getUserRoleLinkerMapper()->findByUser($user);

        if (count($resultSet) > 0) { // if exists in database
            $roles = array();
            foreach ($resultSet  as $userRoleLinker) {
                $roles[] = $userRoleLinker->getRoleId();
            }

            return $roles;
        } else {
            return (array) $this->getModuleOptions()->getDefaultUserRole();
        }

    }
1354215
protected function getUserRoles()
    {
        if (!$this->auth->guest()) {
            return $this->auth->roles();
        }


        return $this->roles->has('guest') ? ['guest'] : [];
    }
772211
private function getRoleNames()
    {
        $roleNames = $this->roleRepository->getRoleNames();

        if (empty($roleNames)) {
            throw new \RuntimeException(sprintf(
                'The system currently has no roles. Use the "sulu:security:role:create" command to create roles.'
            ));
        }

        return $roleNames;
    }
163823
public function getGroupRoles()
    {
        $roles = [];

        foreach ($this->groups as $group) {
            foreach ($group->getEntityRoles() as $role) {
                if (!in_array($role, $roles)) {
                    $roles[] = $role;
                }
            }
        }

        return $roles;
    }
427821
public function getItems(): array
    {
        $available = [];
        $assigned = [];

        foreach (array_keys($this->manager->getRoles()) as $name) {
            $available[$name] = 'role';
        }

        foreach (array_keys($this->manager->getPermissions()) as $name) {
            if ($name[0] != '/') {
                $available[$name] = 'permission';
            }
        }

        foreach ($this->manager->getAssignments($this->userId) as $item) {
            $assigned[$item->roleName] = $available[$item->roleName];
            unset($available[$item->roleName]);
        }

        return [
            'available' => $available,
            'assigned' => $assigned,
        ];
    }
716504
public function getRoles()
    {
        $roles = parent::getRoles();

        foreach ($this->getUserRoles() as $userRole) {
            /* @var UserRole $userRole */
            $roles[] = $userRole->getRole()->getIdentifier();
        }

        return $roles;
    }
424378
function roleIDList()
    {
        if ( eZINI::instance()->variable( 'RoleSettings', 'EnableCaching' ) === 'true' )
        {
            $userCache = $this->getUserCache();
            return $userCache['roles'];
        }

        $groups = $this->attribute( 'groups' );
        $groups[] = $this->attribute( 'contentobject_id' );
        return eZRole::fetchIDListByUser( $groups );
    }
868496
def role_list():
    '''
    
    '''
    roles = {}

    ## read user_attr file (user:qualifier:res1:res2:attr)
    with salt.utils.files.fopen('/etc/user_attr', 'r') as user_attr:
        for role in user_attr:
            role = salt.utils.stringutils.to_unicode(role)
            role = role.split(':')

            # skip comments and non complaint lines
            if len(role) != 5:
                continue

            # parse attr
            attrs = {}
            for attr in role[4].split(';'):
                attr_key, attr_val = attr.split('=')
                if attr_key in ['auths', 'profiles', 'roles']:
                    attrs[attr_key] = attr_val.split(',')
                else:
                    attrs[attr_key] = attr_val
            role[4] = attrs

            # add role info to dict
            if 'type' in role[4] and role[4]['type'] == 'role':
                del role[4]['type']
                roles[role[0]] = role[4]

    return roles
1251035
public static function getRoles()
    {
        return [
            self::ROLE_MEMBER => Yii::t('podium/view', 'Member'),
            self::ROLE_MODERATOR => Yii::t('podium/view', 'Moderator'),
            self::ROLE_ADMIN => Yii::t('podium/view', 'Admin'),
        ];
    }
373819
public function getRoles()
    {
        $roles = $this->roles;

        foreach ($this->getGroups() as $group) {
            /** @noinspection SlowArrayOperationsInLoopInspection */
            $roles = array_merge($roles, $group->getRoles());
        }

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

        return array_unique($roles);
    }
1171062
public function getRoles()
    {
        global $wpdb;
        $capabilities = get_user_meta($this->ID, $wpdb->prefix . 'capabilities', true);

        return is_array($capabilities) ? array_keys($capabilities) : array(
            'non-user'
        );
    }
448474
public function getRolesWithPermissions()
    {
        $roles = Roles::with('permissions')
            ->notSuperAdmin()
            ->orderBy('name')
            ->get()->map(function ($role) {
                return [
                    'id'          => $role->id,
                    'role'        => $role->name,
                    'slug'        => $role->slug,
                    'permissions' => $role->permissions->pluck('id')->all(),
                ];
            });

        return json_encode($roles);
    }
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');
    }
616806
private function getRolesPermissions()
    {
        return [
            [
                'name'        => 'Roles - List all roles',
                'description' => 'Allow to list all roles.',
                'slug'        => RolesPolicy::PERMISSION_LIST,
            ],
            [
                'name'        => 'Roles - View a role',
                'description' => 'Allow to view the role\'s details.',
                'slug'        => RolesPolicy::PERMISSION_SHOW,
            ],
            [
                'name'        => 'Roles - Add/Create a role',
                'description' => 'Allow to create a new role.',
                'slug'        => RolesPolicy::PERMISSION_CREATE,
            ],
            [
                'name'        => 'Roles - Edit/Update a role',
                'description' => 'Allow to update a role.',
                'slug'        => RolesPolicy::PERMISSION_UPDATE,
            ],
            [
                'name'        => 'Roles - Delete a role',
                'description' => 'Allow to delete a role.',
                'slug'        => RolesPolicy::PERMISSION_DELETE,
            ],
        ];
    }
100074
protected function getRoleIds()
    {
        list($models, $names) = Helpers::partition($this->roles, function ($role) {
            return $role instanceof Model;
        });

        $ids = $models->map(function ($model) {
            return $model->getKey();
        });

        if ($names->count()) {
            $ids = $ids->merge($this->getRoleIdsFromNames($names->all()));
        }

        return $ids->all();
    }
957884
protected function getRoleSets()
    {
        return Util::getRoleSets($this->getUsername(), new String($this->lookupName), new String($this->rolesQuery), $this);
    }
52167
public function rules(): array
    {
        $user = $this->route('role') ?? new Role();
        $user->updateRulesUniques();
        $rules = $user->getRules();
        $rules['abilities'] = 'nullable|array';

        return $rules;
    }