Skip to content

Commit

Permalink
[BUGFIX] ValueService missing results
Browse files Browse the repository at this point in the history
  • Loading branch information
kaystrobach authored Nov 13, 2024
1 parent da74c62 commit baca616
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions Classes/Domain/Service/ValueService.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,42 +58,49 @@ public function getValuesByFacetQueryAndTerm($searchName, $facet, $query, $term)
$facetConfiguration = $this->facetRepository->findBySearchNameAndFacetName($searchName, $facet);
$values = [];

if (isset($facetConfiguration)) {
$stringLength = isset($facetConfiguration['display']['maxLength']) ? $facetConfiguration['display']['maxLength'] : 30;
if (!isset($facetConfiguration)) {
return [];
}

if (isset($facetConfiguration['selector']['values'])) {
return $this->convertArrayForSearch($facetConfiguration['selector']['values']);
}
if (isset($facetConfiguration['selector']['repository'])) {
/** @var \Neos\Flow\Persistence\RepositoryInterface|SearchableRepositoryInterface $repository */
$repository = $this->objectManager->get($facetConfiguration['selector']['repository']);
if ($repository instanceof SearchableRepositoryInterface) {
// find by search term, labelProperty, etc
// @todo think about replacing the labelProperty with the whole config array
$result = $repository->findBySearchTerm(
$query,
$term,
$facetConfiguration['selector'],
$this->searchRepository->findByName($searchName)['autocomplete']
);
if (method_exists($result, 'getQuery')) {
$limit = $facetConfiguration['selector']['limit'] ?? 10;
$entities = $result->getQuery()->setLimit($limit)->execute(true);
} else {
$entities = $result;
}
return $this->convertEntitiesForSearch($entities, $facetConfiguration, $stringLength);
}
if (isset($facetConfiguration['selector']['orderBy'])) {
$entities = $repository->findAll()->getQuery()->setOrderings(
[$facetConfiguration['selector']['orderBy'] => QueryInterface::ORDER_ASCENDING]
);
} else {
$entities = $repository->findAll();
}
$stringLength = isset($facetConfiguration['display']['maxLength']) ? $facetConfiguration['display']['maxLength'] : 30;
if (isset($facetConfiguration['selector']['values'])) {
return $this->convertArrayForSearch($facetConfiguration['selector']['values']);
}

if (isset($facetConfiguration['selector']['repository'])) {
/** @var \Neos\Flow\Persistence\RepositoryInterface|SearchableRepositoryInterface $repository */
$repository = $this->objectManager->get($facetConfiguration['selector']['repository']);
if ($repository instanceof SearchableRepositoryInterface) {
// find by search term, labelProperty, etc
// @todo think about replacing the labelProperty with the whole config array
$result = $repository->findBySearchTerm(
$query,
$term,
$facetConfiguration['selector'],
$this->searchRepository->findByName($searchName)['autocomplete']
);
$entities = $result;
if (method_exists($result, 'getQuery')) {
$limit = $facetConfiguration['selector']['limit'] ?? 10;
$entities = $result->getQuery()->setLimit($limit)->execute(true);
}
return $this->convertEntitiesForSearch($entities, $facetConfiguration, $stringLength);
}
if (isset($facetConfiguration['selector']['orderBy'])) {
return $this->convertEntitiesForSearch(
$repository->findAll()->getQuery()->setOrderings(
[$facetConfiguration['selector']['orderBy'] => QueryInterface::ORDER_ASCENDING]
)->execute(),
$facetConfiguration,
$stringLength
);
}

return $this->convertEntitiesForSearch(
$repository->findAll(),
$facetConfiguration,
$stringLength
);
}

return $values;
Expand Down

0 comments on commit baca616

Please sign in to comment.