public function init()
    {
        if (!$this->getQuery()) {
            throw new \RuntimeException('Uninitialized QueryBuilder');
        }

        $this->resetIterator();
        $this->setNbResults($this->computeNbResult());

        if (0 == $this->getPage() || 0 == $this->getMaxPerPage() || 0 == $this->getNbResults()) {
            $this->setLastPage(0);
            $this->getQuery()->setFirstResult(0);
            $this->getQuery()->setMaxResults(0);
        } else {
            $offset = ($this->getPage() - 1) * $this->getMaxPerPage();
            $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage()));
            $this->getQuery()->setFirstResult($offset);
            $this->getQuery()->setMaxResults($this->getMaxPerPage());
        }
    }
public function init()
    {
        if (!$this->getQuery()) {
            throw new \RuntimeException('Uninitialized QueryBuilder');
        }

        $this->resetIterator();
        $this->setNbResults($this->computeNbResult());

        if (0 == $this->getPage() || 0 == $this->getMaxPerPage() || 0 == $this->getNbResults()) {
            $this->setLastPage(0);
            $this->getQuery()->setFirstResult(0);
            $this->getQuery()->setMaxResults(0);
        } else {
            $offset = ($this->getPage() - 1) * $this->getMaxPerPage();
            $this->setLastPage(ceil($this->getNbResults() / $this->getMaxPerPage()));
            $this->getQuery()->setFirstResult($offset);
            $this->getQuery()->setMaxResults($this->getMaxPerPage());
        }
    }
public function init ( ) { if ( ! $ this -> getQuery ( ) ) { throw new \ RuntimeException ( 'Uninitialized QueryBuilder' ) ; } $ this -> resetIterator ( ) ; $ this -> setNbResults ( $ this -> computeNbResult ( ) ) ; if ( 0 == $ this -> getPage ( ) || 0 == $ this -> getMaxPerPage ( ) || 0 == $ this -> getNbResults ( ) ) { $ this -> setLastPage ( 0 ) ; $ this -> getQuery ( ) -> setFirstResult ( 0 ) ; $ this -> getQuery ( ) -> setMaxResults ( 0 ) ; } else { $ offset = ( $ this -> getPage ( ) - 1 ) * $ this -> getMaxPerPage ( ) ; $ this -> setLastPage ( ceil ( $ this -> getNbResults ( ) / $ this -> getMaxPerPage ( ) ) ) ; $ this -> getQuery ( ) -> setFirstResult ( $ offset ) ; $ this -> getQuery ( ) -> setMaxResults ( $ this -> getMaxPerPage ( ) ) ; } }
Initializes the pager setting the offset and maxResults in ProxyQuery
and obtaining the total number of pages.

@throws \RuntimeException the QueryBuilder is uninitialized
Initializes the pager setting the offset and maxResults in ProxyQuery and obtaining the total number of pages .