eZ\Publish\Core\Repository\UserService::loadUsersOfUserGroup PHP Method

loadUsersOfUserGroup() public method

Loads the users of a user group.
public loadUsersOfUserGroup ( eZ\Publish\API\Repository\Values\User\UserGroup $userGroup, integer $offset, integer $limit = 25 ) : eZ\Publish\API\Repository\Values\User\User[]
$userGroup eZ\Publish\API\Repository\Values\User\UserGroup
$offset integer the start offset for paging
$limit integer the number of users returned
return eZ\Publish\API\Repository\Values\User\User[]
    public function loadUsersOfUserGroup(APIUserGroup $userGroup, $offset = 0, $limit = 25)
    {
        $loadedUserGroup = $this->loadUserGroup($userGroup->id);
        if ($loadedUserGroup->getVersionInfo()->getContentInfo()->mainLocationId === null) {
            return array();
        }
        $mainGroupLocation = $this->repository->getLocationService()->loadLocation($loadedUserGroup->getVersionInfo()->getContentInfo()->mainLocationId);
        $searchQuery = new LocationQuery();
        $searchQuery->filter = new CriterionLogicalAnd(array(new CriterionContentTypeId($this->settings['userClassID']), new CriterionParentLocationId($mainGroupLocation->id)));
        $searchQuery->offset = $offset;
        $searchQuery->limit = $limit;
        $searchQuery->performCount = false;
        $searchQuery->sortClauses = $mainGroupLocation->getSortClauses();
        $searchResult = $this->repository->getSearchService()->findLocations($searchQuery);
        $users = array();
        foreach ($searchResult->searchHits as $resultItem) {
            $users[] = $this->buildDomainUserObject($this->userHandler->load($resultItem->valueObject->contentInfo->id), $this->repository->getContentService()->internalLoadContent($resultItem->valueObject->contentInfo->id));
        }
        return $users;
    }