From b31f315ec46176ca5d95dd0300f3bdf344c98d8f Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 6 Sep 2017 22:38:46 +0200 Subject: [PATCH] BUGFIX: Allow iteration / pagination of result items Implement necessary logic based on mapped result items, not elastica result items. --- .../Connection/Elasticsearch/SearchResult.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Classes/Connection/Elasticsearch/SearchResult.php b/Classes/Connection/Elasticsearch/SearchResult.php index 46ffb14..f45f02f 100644 --- a/Classes/Connection/Elasticsearch/SearchResult.php +++ b/Classes/Connection/Elasticsearch/SearchResult.php @@ -48,6 +48,13 @@ class SearchResult implements SearchResultInterface */ protected $results = []; + /** + * For Iterator interface. + * + * @var int + */ + protected $position = 0; + /** * @var ObjectManagerInterface */ @@ -121,27 +128,29 @@ class SearchResult implements SearchResultInterface // Iterator - Interface public function current() { - return $this->result->current(); + return $this->getResults()[$this->position]; } public function next() { - return $this->result->next(); + ++$this->position; + + return $this->current(); } public function key() { - return $this->result->key(); + return $this->position; } public function valid() { - return $this->result->valid(); + return isset($this->getResults()[$this->position]); } public function rewind() { - $this->result->rewind(); + $this->position = 0; } // Extbase QueryResultInterface - Implemented to support Pagination of Fluid.