/** * 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 * @param array $languageFilter * @param bool $doCount * * @throws \RuntimeException * * @return mixed[][] */ public function find(Criterion $criterion, $offset = 0, $limit = null, array $sortClauses = null, array $languageFilter = array(), $doCount = true) { try { return $this->innerGateway->find($criterion, $offset, $limit, $sortClauses, $languageFilter, $doCount); } catch (DBALException $e) { throw new RuntimeException('Database error', 0, $e); } catch (PDOException $e) { throw new RuntimeException('Database error', 0, $e); } }
/** * @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; }
/** * @see \eZ\Publish\SPI\Search\Content\Location\Handler::findLocations */ public function findLocations(LocationQuery $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 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, $query->performCount); $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; }