provider = $pagedRouteProvider; $this->routesBatchSize = $routesBatchSize; } /** * Loads the next routes into the elements array. * * @param int $offset The offset used in the db query. */ protected function loadNextElements($offset) { // If the last batch was smaller than the batch size, this means there // are no more routes available. if (isset($this->currentRoutes) && count($this->currentRoutes) < $this->routesBatchSize) { $this->currentRoutes = array(); } else { $this->currentRoutes = $this->provider->getRoutesPaged($offset, $this->routesBatchSize); } } /** * {@inheritdoc} */ public function current() { return current($this->currentRoutes); } /** * {@inheritdoc} */ public function next() { $result = next($this->currentRoutes); if (false === $result) { $this->loadNextElements($this->current + 1); } ++$this->current; } /** * {@inheritdoc} */ public function key() { return key($this->currentRoutes); } /** * {@inheritdoc} */ public function valid() { return key($this->currentRoutes); } /** * {@inheritdoc} */ public function rewind() { $this->current = 0; $this->currentRoutes = null; $this->loadNextElements($this->current); } /** * Gets the number of Routes in this collection. * * @return int The number of routes */ public function count() { return $this->provider->getRoutesCount(); } }