From b23b92f9504a2130fac3455cd79d7f116fa7deba Mon Sep 17 00:00:00 2001 From: Ambroise Maupate Date: Tue, 14 Mar 2023 11:31:23 +0100 Subject: [PATCH] feat: Create overrideable `createSearchResultsFromResponse` method for any AbstractSearchHandler extending class --- .../src/SearchEngine/AbstractSearchHandler.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/RoadizCoreBundle/src/SearchEngine/AbstractSearchHandler.php b/lib/RoadizCoreBundle/src/SearchEngine/AbstractSearchHandler.php index 8175a7fb..b81fa233 100644 --- a/lib/RoadizCoreBundle/src/SearchEngine/AbstractSearchHandler.php +++ b/lib/RoadizCoreBundle/src/SearchEngine/AbstractSearchHandler.php @@ -67,6 +67,11 @@ public function searchWithHighlight( $args["fq"][] = "document_type_s:" . $this->getDocumentType(); $args = array_merge($this->getHighlightingOptions($args), $args); $response = $this->nativeSearch($q, $args, $rows, $searchTags, $proximity, $page); + return $this->createSearchResultsFromResponse($response); + } + + protected function createSearchResultsFromResponse(?array $response): SolrSearchResults + { return new SolrSearchResults(null !== $response ? $response : [], $this->em); } @@ -204,7 +209,7 @@ public function search( $args = array_merge($tmp, $args); $response = $this->nativeSearch($q, $args, $rows, $searchTags, $proximity, $page); - return new SolrSearchResults(null !== $response ? $response : [], $this->em); + return $this->createSearchResultsFromResponse($response); } /**