BUGFIX: Allow iteration / pagination of result items

Implement necessary logic based on mapped result items, not elastica
result items.
This commit is contained in:
Daniel Siepmann 2017-09-06 22:38:46 +02:00
parent d45d231585
commit b31f315ec4
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4

View file

@ -48,6 +48,13 @@ class SearchResult implements SearchResultInterface
*/ */
protected $results = []; protected $results = [];
/**
* For Iterator interface.
*
* @var int
*/
protected $position = 0;
/** /**
* @var ObjectManagerInterface * @var ObjectManagerInterface
*/ */
@ -121,27 +128,29 @@ class SearchResult implements SearchResultInterface
// Iterator - Interface // Iterator - Interface
public function current() public function current()
{ {
return $this->result->current(); return $this->getResults()[$this->position];
} }
public function next() public function next()
{ {
return $this->result->next(); ++$this->position;
return $this->current();
} }
public function key() public function key()
{ {
return $this->result->key(); return $this->position;
} }
public function valid() public function valid()
{ {
return $this->result->valid(); return isset($this->getResults()[$this->position]);
} }
public function rewind() public function rewind()
{ {
$this->result->rewind(); $this->position = 0;
} }
// Extbase QueryResultInterface - Implemented to support Pagination of Fluid. // Extbase QueryResultInterface - Implemented to support Pagination of Fluid.