public function buildLocationDomainObjectsOnSearchResult(SearchResult $result, array $languageFilter)
    {
        if (empty($result->searchHits)) {
            return [];
        }

        $contentIds = [];
        foreach ($result->searchHits as $hit) {
            $contentIds[] = $hit->valueObject->contentId;
        }

        $missingLocations = [];
        $contentInfoList = $this->contentHandler->loadContentInfoList($contentIds);
        $contentList = $this->buildContentProxyList(
            $contentInfoList,
            !empty($languageFilter['languages']) ? $languageFilter['languages'] : []
        );
        foreach ($result->searchHits as $key => $hit) {
            if (isset($contentInfoList[$hit->valueObject->contentId])) {
                $hit->valueObject = $this->buildLocationWithContent(
                    $hit->valueObject,
                    $contentList[$hit->valueObject->contentId],
                    $contentInfoList[$hit->valueObject->contentId]
                );
            } else {
                $missingLocations[] = $hit->valueObject;
                unset($result->searchHits[$key]);
                --$result->totalCount;
            }
        }

        return $missingLocations;
    }
public function buildLocationDomainObjectsOnSearchResult(SearchResult $result, array $languageFilter)
    {
        if (empty($result->searchHits)) {
            return [];
        }

        $contentIds = [];
        foreach ($result->searchHits as $hit) {
            $contentIds[] = $hit->valueObject->contentId;
        }

        $missingLocations = [];
        $contentInfoList = $this->contentHandler->loadContentInfoList($contentIds);
        $contentList = $this->buildContentProxyList(
            $contentInfoList,
            !empty($languageFilter['languages']) ? $languageFilter['languages'] : []
        );
        foreach ($result->searchHits as $key => $hit) {
            if (isset($contentInfoList[$hit->valueObject->contentId])) {
                $hit->valueObject = $this->buildLocationWithContent(
                    $hit->valueObject,
                    $contentList[$hit->valueObject->contentId],
                    $contentInfoList[$hit->valueObject->contentId]
                );
            } else {
                $missingLocations[] = $hit->valueObject;
                unset($result->searchHits[$key]);
                --$result->totalCount;
            }
        }

        return $missingLocations;
    }
public function buildLocationDomainObjectsOnSearchResult ( SearchResult $ result , array $ languageFilter ) { if ( empty ( $ result -> searchHits ) ) { return [ ] ; } $ contentIds = [ ] ; foreach ( $ result -> searchHits as $ hit ) { $ contentIds [ ] = $ hit -> valueObject -> contentId ; } $ missingLocations = [ ] ; $ contentInfoList = $ this -> contentHandler -> loadContentInfoList ( $ contentIds ) ; $ contentList = $ this -> buildContentProxyList ( $ contentInfoList , ! empty ( $ languageFilter [ 'languages' ] ) ? $ languageFilter [ 'languages' ] : [ ] ) ; foreach ( $ result -> searchHits as $ key => $ hit ) { if ( isset ( $ contentInfoList [ $ hit -> valueObject -> contentId ] ) ) { $ hit -> valueObject = $ this -> buildLocationWithContent ( $ hit -> valueObject , $ contentList [ $ hit -> valueObject -> contentId ] , $ contentInfoList [ $ hit -> valueObject -> contentId ] ) ; } else { $ missingLocations [ ] = $ hit -> valueObject ; unset ( $ result -> searchHits [ $ key ] ) ; -- $ result -> totalCount ; } } return $ missingLocations ; }
Build API Location and corresponding ContentInfo domain objects and apply to LocationSearchResult.

This is done in order to be able to:
Load ContentInfo objects in bulk, generate proxy objects for Content that will loaded in bulk on-demand (on use).

@param \eZ\Publish\API\Repository\Values\Content\Search\SearchResult $result SPI search result with SPI Location items as hits
@param array $languageFilter

@return \eZ\Publish\SPI\Persistence\Content\Location[] Locations we did not find content info for is returned.
Build API Location and corresponding ContentInfo domain objects and apply to LocationSearchResult .