Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SearchResultIterator.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Framework\Data;
7 
9 
13 class SearchResultIterator implements \Iterator
14 {
18  protected $searchResult;
19 
23  protected $query;
24 
28  protected $current;
29 
33  protected $key = 0;
34 
40  {
41  $this->searchResult = $searchResult;
42  $this->query = $query;
43  }
44 
48  public function current()
49  {
50  return $this->current;
51  }
52 
56  public function next()
57  {
58  ++$this->key;
59  $this->current = $this->searchResult->createDataObject($this->query->fetchItem());
60  }
61 
65  public function key()
66  {
67  return $this->key;
68  }
69 
73  public function valid()
74  {
75  return !empty($this->current);
76  }
77 
81  public function rewind()
82  {
83  $this->current = null;
84  $this->key = 0;
85  $this->query->reset();
86  $this->next();
87  }
88 }
__construct(AbstractSearchResult $searchResult, QueryInterface $query)