eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper::createLocationsFromRows PHP Method

createLocationsFromRows() public method

Creates Location objects from the given $rows, optionally with key $prefix.
public createLocationsFromRows ( array $rows, string $prefix = '' ) : eZ\Publish\SPI\Persistence\Content\Location[]
$rows array
$prefix string
return eZ\Publish\SPI\Persistence\Content\Location[]
    public function createLocationsFromRows(array $rows, $prefix = '')
    {
        $locations = array();
        foreach ($rows as $row) {
            $id = $row[$prefix . 'node_id'];
            if (!isset($locations[$id])) {
                $locations[$id] = $this->createLocationFromRow($row, $prefix);
            }
        }
        return array_values($locations);
    }

Usage Example

Beispiel #1
0
 /**
  * @see \eZ\Publish\SPI\Search\Handler::findLocations
  */
 public function findLocations(LocationQuery $query, array $languageFilter = array())
 {
     if (!isset($languageFilter['languages'])) {
         $languageFilter['languages'] = array();
     }
     if (!isset($languageFilter['useAlwaysAvailable'])) {
         $languageFilter['useAlwaysAvailable'] = true;
     }
     $start = microtime(true);
     $query->filter = $query->filter ?: new Criterion\MatchAll();
     $query->query = $query->query ?: new Criterion\MatchAll();
     if (count($query->facetBuilders)) {
         throw new NotImplementedException('Facets are not supported by the legacy search engine.');
     }
     // The legacy search does not know about scores, so we just
     // combine the query with the filter
     $data = $this->locationGateway->find(new Criterion\LogicalAnd(array($query->query, $query->filter)), $query->offset, $query->limit, $query->sortClauses, $languageFilter, $query->performCount);
     $result = new SearchResult();
     $result->time = microtime(true) - $start;
     $result->totalCount = $data['count'];
     $locationList = $this->locationMapper->createLocationsFromRows($data['rows']);
     foreach ($locationList as $index => $location) {
         $searchHit = new SearchHit();
         $searchHit->valueObject = $location;
         $searchHit->matchedTranslation = $this->extractMatchedLanguage($data['rows'][$index]['language_mask'], $data['rows'][$index]['initial_language_id'], $languageFilter);
         $result->searchHits[] = $searchHit;
     }
     return $result;
 }
All Usage Examples Of eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper::createLocationsFromRows