From 564ca1511c1b8dcacc20b7fae7eb4ef9dc7c7fe5 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Sat, 29 Dec 2018 18:07:25 +0100 Subject: [PATCH] TASK: Refactor code into common flow As we have the same flow in some more places, we refactor this part to follow this conventions. --- .../Connection/Elasticsearch/SearchResult.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/Classes/Connection/Elasticsearch/SearchResult.php b/Classes/Connection/Elasticsearch/SearchResult.php index f178c68..cd3db0a 100644 --- a/Classes/Connection/Elasticsearch/SearchResult.php +++ b/Classes/Connection/Elasticsearch/SearchResult.php @@ -121,14 +121,17 @@ class SearchResult implements SearchResultInterface } $this->facets = []; - if ($this->result->hasAggregations()) { - foreach ($this->result->getAggregations() as $aggregationName => $aggregation) { - $this->facets[$aggregationName] = $this->objectManager->get( - Facet::class, - $aggregationName, - $aggregation - ); - } + + if ($this->result->hasAggregations() === false) { + return; + } + + foreach ($this->result->getAggregations() as $aggregationName => $aggregation) { + $this->facets[$aggregationName] = $this->objectManager->get( + Facet::class, + $aggregationName, + $aggregation + ); } }