createLocationsFromRows() публичный Метод

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
Результат eZ\Publish\SPI\Persistence\Content\Location[]
Пример #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;
 }
Пример #2
0
 /**
  * @see \eZ\Publish\SPI\Persistence\Content\Location\Search\Handler::findLocations
  */
 public function findLocations(LocationQuery $query)
 {
     $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->gateway->find(new Criterion\LogicalAnd(array($query->query, $query->filter)), $query->offset, $query->limit, $query->sortClauses);
     $result = new SearchResult();
     $result->time = microtime(true) - $start;
     $result->totalCount = $data['count'];
     foreach ($this->locationMapper->createLocationsFromRows($data['rows']) as $location) {
         $result->searchHits[] = new SearchHit(array("valueObject" => $location));
     }
     return $result;
 }
Пример #3
0
 /**
  * @covers eZ\Publish\Core\Persistence\Legacy\Content\Location\Mapper::createLocationsFromRows
  */
 public function testCreateLocationsFromRows()
 {
     $inputRows = array();
     for ($i = 0; $i < 3; $i++) {
         $row = $this->locationRow;
         $row['node_id'] += $i;
         $inputRows[] = $row;
     }
     $mapper = new Mapper();
     $locations = $mapper->createLocationsFromRows($inputRows);
     $this->assertCount(3, $locations);
     foreach ($locations as $location) {
         $this->assertInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Location', $location);
     }
 }
Пример #4
0
 /**
  * @see \eZ\Publish\SPI\Persistence\Content\Location\Handler::loadParentLocationsForDraftContent
  */
 public function loadParentLocationsForDraftContent($contentId)
 {
     $rows = $this->locationGateway->loadParentLocationsDataForDraftContent($contentId);
     return $this->locationMapper->createLocationsFromRows($rows);
 }