public function findLocations(LocationQuery $query) { $searchResult = $this->searchService->findLocations($query, ['languages' => $this->prioritizedLanguages, 'useAlwaysAvailable' => $this->useAlwaysAvailable]); foreach ($searchResult->searchHits as $searchHit) { /** @var \eZ\Publish\API\Repository\Values\Content\Location $location */ $location = $searchHit->valueObject; $searchHit->valueObject = $this->domainObjectMapper->mapLocation($location, $this->contentService->loadVersionInfo($location->contentInfo, $location->contentInfo->currentVersionNo), $searchHit->matchedTranslation); } return $searchResult; }
/** * Returns Site Location object for the given Repository $location. * * @throws \Netgen\EzPlatformSiteApi\Core\Site\Exceptions\TranslationNotMatchedException * * @param \eZ\Publish\API\Repository\Values\Content\Location $location * * @return \Netgen\EzPlatformSiteApi\API\Values\Location */ private function getSiteLocation(APILocation $location) { $versionInfo = $this->contentService->loadVersionInfoById($location->contentInfo->id); $languageCode = $this->getLanguage($versionInfo->languageCodes, $versionInfo->contentInfo->mainLanguageCode, $versionInfo->contentInfo->alwaysAvailable); if ($languageCode === null) { throw new TranslationNotMatchedException($versionInfo->contentInfo->id, $this->getContext($versionInfo)); } return $this->domainObjectMapper->mapLocation($location, $versionInfo, $languageCode); }