mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 12:16:11 +01:00
Merge pull request #84 from Codappix/hotfix/fix-broken-iteration-of-results
BUGFIX: Allow iteration / pagination of result items
This commit is contained in:
commit
e354e740ca
1 changed files with 14 additions and 5 deletions
|
@ -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.
|
||||||
|
|
Loading…
Reference in a new issue