public function loadSubUserGroups(APIUserGroup $userGroup, $offset = 0, $limit = 25)
{
$locationService = $this->repository->getLocationService();
$loadedUserGroup = $this->loadUserGroup($userGroup->id);
if (!$this->repository->canUser('content', 'read', $loadedUserGroup)) {
throw new UnauthorizedException('content', 'read');
}
if ($loadedUserGroup->getVersionInfo()->getContentInfo()->mainLocationId === null) {
return array();
}
$mainGroupLocation = $locationService->loadLocation($loadedUserGroup->getVersionInfo()->getContentInfo()->mainLocationId);
$searchResult = $this->searchSubGroups($mainGroupLocation, $offset, $limit);
if ($searchResult->totalCount == 0) {
return array();
}
$subUserGroups = array();
foreach ($searchResult->searchHits as $searchHit) {
$subUserGroups[] = $this->buildDomainUserGroupObject($this->repository->getContentService()->internalLoadContent($searchHit->valueObject->contentInfo->id));
}
return $subUserGroups;
}