Exemplo n.º 1
0
 /**
  * Returns total count and data for all Locations satisfying the parameters.
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $criterion
  * @param int $offset
  * @param int|null $limit
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sortClauses
  *
  * @return mixed[][]
  */
 public function find(Criterion $criterion, $offset = 0, $limit = null, array $sortClauses = null)
 {
     try {
         return $this->innerGateway->find($criterion, $offset, $limit, $sortClauses);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }
Exemplo n.º 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;
 }