getUserRolesEntities()

@param mixed[] $userRoles  roles assigned to specified user
@return mixed[]            list of user's roles entities
339479
public function getUserRolesEntities(array $userRoles): array
    {
        $query = $this->find('list')->where(['role_id IN' => array_keys($userRoles)]);
        $entities = $query->all();
        if (!$entities->isEmpty()) {
            return array_values($entities->toArray());
        }

        return [];
    }
1027408
public function getRoles()
    {
        $roleModel = new \erdiko\users\models\Role;
        $roleEntity = $roleModel->findById($this->_user->getRole());
		return array( $roleEntity->getName());
	}
809171
public function getReachableRoleNames(array $roles): array
    {
        $reachableRoles = $roles;

        foreach ($roles as $role) {
            if (!isset($this->map[$role])) {
                continue;
            }

            foreach ($this->map[$role] as $r) {
                $reachableRoles[] = $r;
            }
        }

        return $reachableRoles;
    }
1038069
protected function getRoles() {
        if (!$this->_roles) {
            $this->_roles = new RoleList($this->version, $this->solution['sid']);
        }

        return $this->_roles;
    }
276113
public static function getServerListByRoles(array $roles)
    {
        $servers = [];
        foreach ($roles as $roleCode) {
            $rolesForCode = RoleManager::getServersByRole($roleCode);

            foreach ($rolesForCode as $serverCode) {
                if (in_array($serverCode, $servers, true)) {
                    continue;
                }

                $servers[] = $serverCode;
            }
        }

        return $servers;
    }
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'] : []);
    }
1088680
private function getRoleNames(array $sids)
    {
        $roles = [];

        foreach ($sids as $sid) {
            if ($sid instanceof RoleSecurityIdentity) {
                $roles[] = $sid->getIdentifier();
            }
        }

        return $roles;
    }
1029364
def get_user_roles(user):
    """"""
    if not hasattr(user, '_role_cache'):
        user._role_cache = list(TenantRole.objects.filter(user=user).values_list(
            'group', 'role', 'tenant'))
    return user._role_cache
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;
    }
864611
public function getRoleNames($roles)
    {
        $roles = Helpers::groupModelsAndIdentifiersByType($roles);

        $roles['integers'] = $this->getNamesByKey($roles['integers']);

        $roles['models'] = Arr::pluck($roles['models'], 'name');

        return Arr::collapse($roles);
    }
657733
public function findUserIdsInRoles($roleNames)
    {
        $qb = $this->createQueryBuilder('user')
            ->select('user.id')
            ->leftJoin('user.roles', 'roles')
            ->andWhere('roles.name IN (:roleNames)')
            ->andWhere('user.isEnabled = true')
            ->setParameter('roleNames', $roleNames);
        $query = $qb->getQuery();

        return $query->getArrayResult();
    }
775699
protected static function getOrganizationUserRoles(OrganizationUserInterface $user, $roleHierarchy = null)
    {
        $roles = [];

        if ($user instanceof RoleableInterface && $user instanceof OrganizationUserInterface) {
            $org = $user->getOrganization();
            $roles = self::buildOrganizationUserRoles($roles, $user, $org->getName());
            $roles = self::buildOrganizationRoles($roles, $org);

            if ($roleHierarchy instanceof RoleHierarchyInterface) {
                $roles = RoleUtil::formatNames($roleHierarchy->getReachableRoles($roles));
            }
        }

        return $roles;
    }
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;
    }
279314
public function checkRole(array $roles)
    {
        // Find a user which matches the required roles.
        $user = $this->getCustomerUser();

        if (! $this->hasRequiredRole($user, $roles)) {
            $user = $this->getAdminUser();

            if (! $this->hasRequiredRole($user, $roles)) {
                $user = null;
            }
        }

        return $user;
    }
843861
public function findUsersByRolesIncludingGroups(
        array $roles,
        $executeQuery = true
    )
    {
        $dql = "
            SELECT u, r1, g, r2, ws
            From Claroline\CoreBundle\Entity\User u
            LEFT JOIN u.roles r1
            LEFT JOIN u.personalWorkspace ws
            LEFT JOIN u.groups g
            LEFT JOIN g.roles r2
            WHERE (r1 in (:roles)
            OR r2 in (:roles))
            AND u.isEnabled = true
            ORDER BY u.lastName, u.firstName ASC";

        $query = $this->_em->createQuery($dql);
        $query->setParameter('roles', $roles);

        return ($executeQuery) ? $query->getResult() : $query;
    }
563357
public function getAllIncludedRoles (array $roles)
    {
        $allIncludedRoles = [];
        foreach ($this->normalizeRoleList($roles) as $role)
        {
            $includedRoleCollection = [];
            $this->findIncludedRoles($role, $includedRoleCollection);
            $allIncludedRoles = array_replace($allIncludedRoles, $includedRoleCollection);

            $includedActionCollection = [];
            $this->findIncludedActions($role, $includedActionCollection);
            $allIncludedRoles = array_replace($allIncludedRoles, $includedActionCollection);
        }

        return $allIncludedRoles;
    }
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();
		}
	}