/** * {@inheritdoc} */ public function valid() { if (array_key_exists($this->key, $this->documents)) { return true; } $raw = $this->repository->scan($this->scrollId, $this->scrollDuration, Repository::RESULTS_RAW); $this->setScrollId($raw['_scroll_id']); $this->documents = array_merge($this->documents, $raw['hits']['hits']); return isset($this->documents[$this->key]); }
/** * {@inheritdoc} */ public function valid() { if (parent::key() !== null) { return true; } if ($this->key >= $this->getTotalCount()) { return false; } $this->rawData = $this->repository->scan($this->scrollId, $this->scrollDuration, Repository::RESULTS_RAW); $this->setScrollId($this->rawData['_scroll_id']); $this->documents =& $this->rawData['hits']['hits']; return reset($this->documents) !== false; }