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;
}