Get an array of fully qualified user roles

@param string Comma-separated list of roles

@return array Array of roles
977364
public static function parseRoles($rolesString)
    {
        $rolesArray = explode(',', $rolesString);
        $roles = [];
        foreach ($rolesArray as $role) {
            $role = trim($role);
            if (!empty($role)) {
                if (substr($role, 0, 4) != 'urn:') {
                    $role = 'urn:lti:role:ims/lis/' . $role;
                }
                $roles[] = $role;
            }
        }

        return $roles;
    }
574797
private function getRoles($request)
    {
        $routeActions = $this->getActions($request);

        $roles = array_get($routeActions, 'is', []);

        return is_array($roles) ? $roles : (array) $roles;
    }
1025960
public function getRoles($domain = false, $expanded = true)
    {
        $pool = $this->pool;
        $tokenStorage = $this->tokenStorage;
        $authorizationChecker = $this->authorizationChecker;
        $rolesHierarchyList = $this->rolesHierarchy;

        $roles = [];
        $rolesReadOnly = [];

        if (!$tokenStorage->getToken()) {
            return [$roles, $rolesReadOnly];
        }

        $isMaster = $authorizationChecker->isGranted('ROLE_SUPER_ADMIN');

        // get roles from the service container
        foreach ($rolesHierarchyList as $name => $rolesHierarchy) {
            if ($isMaster || $authorizationChecker->isGranted($name)) {
                $roles[$name] = $name;

                /** @var array $rolesHierarchy */
                foreach ($rolesHierarchy as $role) {
                    if (!isset($roles[$role]) && !\in_array($role, [
                            'ROLE_SONATA_ADMIN',
                            'ROLE_USER',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_LIST',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_CREATE',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_VIEW',
                            'ROLE_SONATA_MEDIA_ADMIN_MEDIA_EDIT',
                        ], true)) {
                        $roles[$role] = $role;
                    }
                }
            }
        }

        // get roles from the Admin classes
        foreach ($pool->getAdminServiceIds() as $id) {
            try {
                $admin = $pool->getInstance($id);
            } catch (\Exception $e) {
                continue;
            }

            $isMaster = $admin->isGranted('MASTER');
            $securityHandler = $admin->getSecurityHandler();

            $baseRole = $securityHandler->getBaseRole($admin);

            if ('' === $baseRole) { // the security handler related to the admin does not provide a valid string
                continue;
            }

            $items = [
                'LIST',
                'VIEW',
                'EDIT',
                'CREATE',
                'DELETE',
                'UNDELETE',
                'EXPORT',
                'IMPORT',
                'SETTINGS',
            ];

            if (\in_array($id, [
                'sonata.media.admin.media',
                'sonata.media.admin.gallery',
                'sonata.media.admin.gallery_has_media',
                'sonata.page.admin.snapshot',
                'sonata.page.admin.shared_block',
            ], true)) {
                continue;
            }

            foreach ($items as $role_item) {
                $role = sprintf($baseRole, $role_item);

                //$role_label = $translator->trans($admin->getLabel(), [], $admin->getTranslationDomain())
                //    . ' - '
                //    . $translator->trans('ROLE_' . $role_item, [], $admin->getTranslationDomain());

                $role_label = $role;

                if ($isMaster) {
                    // if the user has the MASTER permission, allow to grant access the admin roles to other users
                    $roles[$role] = $role_label;
                } elseif ($authorizationChecker->isGranted($role)) {
                    // although the user has no MASTER permission, allow the currently logged in user to view the role
                    $rolesReadOnly[$role] = $role_label;
                }
            }
        }

        return $roles;
    }
716504
public function getRoles()
    {
        $roles = parent::getRoles();

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

        return $roles;
    }
326379
public function getAllPermissionsForUser($user)
    {
        $user = $this->resolveUser($user);

        if ( ! $user) {
            return [];
        }

        $permissions = [];

        // Get all permissions for the roles this user belongs to
        foreach ($user->getRoles() as $role) {
            /** @var EloquentRole $role */
            $permissions = array_merge(
                $permissions,
                array_keys(array_filter($role->getPermissions()))
            );
        }

        // Add permissions set specifically for the user
        $permissions = array_merge(
            $permissions,
            array_keys(array_filter($user->getPermissions()))
        );

        sort($permissions);

        return array_unique($permissions);
    }
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);
    }
1008252
public static function getRoles($userId)
    {
        global $PPHP;
        $db = $PPHP['db'];
        $roles = $db->selectList("SELECT role FROM users_roles WHERE userId=? ORDER BY role ASC", array($userId));
        return $roles !== false ? $roles : array();
    }
1184991
function getRoles (session) {
    // return roles from session or default
    return session && Array.isArray(session.roles)
        ? session.roles
        // default roles
        : ['all', (session && session.accountId ? 'authenticated' : 'anonymous')]
}
735991
public function getGroupsRoles(array $userGroups = []): array
    {
        $key = implode('.', $userGroups);

        if (!empty($this->_groupsRoles[$key])) {
            return $this->_groupsRoles[$key];
        }

        $result = [];

        if (!empty($userGroups)) {
            $query = $this->Roles->find('list', [
                'keyField' => 'id',
                'valueField' => 'name'
            ]);
            $query->matching('Groups', function ($q) use ($userGroups) {
                return $q->where(['Groups.id IN' => array_keys($userGroups)])->applyOptions(['accessCheck' => false]);
            });
            $result = $query->toArray();
        }

        $this->_groupsRoles[$key] = $result;

        return $this->_groupsRoles[$key];
    }
560366
public function getRoles()
    {
        $roles = $this->getExplicitRoles();

        if (!$roles) {
            return null;
        }

        $finalRoles = array();
        foreach ($roles as $role) {
            $childRoles = $role->getChildRoles();

            foreach ($childRoles as $childRole) {
                if (!in_array($childRole, $finalRoles)) {
                    $finalRoles[] = $childRole;
                }
            }

            if (!in_array($role, $finalRoles)) {
                $finalRoles[] = $role;
            }
        }

        return $finalRoles;
    }
534654
public function getSearchableRules(): array
    {
        return [
            'roles:[]' => function (Builder $query, array $roles) {
                return $query->whereHas('roles', function (Builder $query) use ($roles) {
                    return $query->whereIn(Role::column('name'), $roles);
                });
            },
        ];
    }
336450
public function roles(): array
    {
        return array_merge(array(),
            ...array_map(
                function (Attribute $attr) {
                    return $attr->values();
                }, $this->allOf(AttributeType::OID_ROLE)));
    }
1105231
public function getUserRoles() {
        $returnValue = $this->internalSession->getUserRoles();
        foreach (array_keys($returnValue) as $key) {
            $role = $returnValue[$key];
            if (!in_array($role, $this->filter)) {
                unset($returnValue[$key]);
            }
        }
        return $returnValue;
    }
885436
public function getRoles()
    {
        if (count($this->rolesStringAsArray) > 0) {
            return $this->rolesStringAsArray;
        }

        $roleNames = array();

        foreach ($this->getEntityRoles(true) as $role) {
            $roleNames[] = $role->getName();
        }

        return $roleNames;
    }
1157381
public function getRoles() {
		if ( $this->cacheEnabled() ) {
			if ( is_null( $this->getCachedRoles() ) ) {
				Cache::remember( 'roles.user_' . $this->id, config( 'roles.cache.expiry' ), function () {
					return $this->roles()->get();
				} );
			}

			return $this->getCachedRoles();
		} else {
			return $this->roles()->get();
		}
	}
1285138
private function getRoles()
    {
        $result = array();
         
        foreach ($this->roles as $name => $rolesHierarchy) {
            $result[$name] = $name;
             
            foreach ($rolesHierarchy as $role) {
                if (!isset($result[$role])) {
                    $result[$role] = $role;
                }
            }
        }
        
        return $result;
    }
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');
    }