Doctrine\ODM\MongoDB\Query\Query::getIterator PHP Method

getIterator() public method

public getIterator ( array $options = [] )
$options array
    public function getIterator(array $options = array())
    {
        if ($this->iterator === null) {
            $iterator = $this->execute($options);
            if ($iterator !== null && !$iterator instanceof Iterator) {
                throw new \BadMethodCallException('Query execution did not return an iterator. This query may not support returning iterators. ');
            }
            $this->iterator = $iterator;
        }
        return $this->iterator;
    }

Usage Example

 /**
  * @return \Doctrine\MongoDB\Iterator
  */
 public function getIterator()
 {
     return $this->query->getIterator();
 }