/**
  * Returns a list of object satisfying the $criterion.
  *
  * @param Criterion $criterion
  * @param int $offset
  * @param int|null $limit
  * @param \eZ\Publish\API\Repository\Values\Content\Query\SortClause[] $sort
  * @param string[] $translations
  *
  * @return mixed[][]
  */
 public function find(Criterion $criterion, $offset = 0, $limit = null, array $sort = null, array $translations = null)
 {
     try {
         return $this->innerGateway->find($criterion, $offset, $limit, $sort, $translations);
     } catch (DBALException $e) {
         throw new RuntimeException('Database error', 0, $e);
     } catch (PDOException $e) {
         throw new RuntimeException('Database error', 0, $e);
     }
 }
Esempio n. 2
0
 /**
  * Finds content objects for the given query.
  *
  * @todo define structs for the field filters
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if Query criterion is not applicable to its target
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Query $query
  * @param array $fieldFilters - a map of filters for the returned fields.
  *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
  */
 public function findContent(Query $query, array $fieldFilters = array())
 {
     $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 that we just
     // combine the query with the filter
     $filter = new Criterion\LogicalAnd(array($query->query, $query->filter));
     $data = $this->gateway->find($filter, $query->offset, $query->limit, $query->sortClauses, null);
     $result = new SearchResult();
     $result->time = microtime(true) - $start;
     $result->totalCount = $data['count'];
     foreach ($this->contentMapper->extractContentInfoFromRows($data['rows'], '', 'main_tree_') as $contentInfo) {
         $searchHit = new SearchHit();
         $searchHit->valueObject = $contentInfo;
         $result->searchHits[] = $searchHit;
     }
     return $result;
 }