public function findContent(Query $query) { $searchResult = $this->searchService->findContentInfo($query, ['languages' => $this->prioritizedLanguages, 'useAlwaysAvailable' => $this->useAlwaysAvailable]); foreach ($searchResult->searchHits as $searchHit) { /** @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */ $contentInfo = $searchHit->valueObject; $searchHit->valueObject = $this->domainObjectMapper->mapContent($this->contentService->loadContent($contentInfo->id, [$searchHit->matchedTranslation]), $searchHit->matchedTranslation); } return $searchResult; }
public function loadContent($contentId, $versionNo = null, $languageCode = null) { $versionInfo = $this->contentService->loadVersionInfoById($contentId, $versionNo); if ($languageCode === null) { $languageCode = $this->getLanguage($versionInfo->languageCodes, $versionInfo->contentInfo->mainLanguageCode, $versionInfo->contentInfo->alwaysAvailable); if ($languageCode === null) { throw new TranslationNotMatchedException($contentId, $this->getContext($versionInfo)); } } elseif (!in_array($languageCode, $versionInfo->languageCodes)) { throw new TranslationNotMatchedException($contentId, $this->getContext($versionInfo)); } $content = $this->contentService->loadContent($contentId, [$languageCode], $versionNo); return $this->domainObjectMapper->mapContent($content, $languageCode); }