Merge pull request #84 from Codappix/hotfix/fix-broken-iteration-of-results

BUGFIX: Allow iteration / pagination of result items
This commit is contained in:
Daniel Siepmann 2017-09-07 08:04:20 +02:00 committed by GitHub
commit e354e740ca

View file

@ -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.