/** * Return real usable Paginator instance given the definition type * * @param Paginator $paginator Paginator * @param string $parameterType Parameter type * @param int $limitPerPage * @param int $page * * @return mixed Paginator instance */ public function decidePaginatorFormat(Paginator $paginator, $parameterType, $limitPerPage, $page) { if ('Pagerfanta\\Pagerfanta' === $parameterType) { $paginator = new Pagerfanta(new DoctrineORMAdapter($paginator->getQuery())); $paginator->setMaxPerPage($limitPerPage); $paginator->setCurrentPage($page); } return $paginator; }
/** * Return real usable Paginator instance given the definition type * * @param Paginator $paginator Paginator * @param string $parameterType Parameter type * @param int $limitPerPage * @param int $page * * @return mixed Paginator instance */ public function decidePaginatorFormat(Paginator $paginator, $parameterType, $limitPerPage, $page) { if ('Pagerfanta\\Pagerfanta' === $parameterType) { $paginator = new Pagerfanta(new DoctrineORMAdapter($paginator->getQuery())); $paginator->setMaxPerPage($limitPerPage); $paginator->setCurrentPage($page); } if ('Knp\\Component\\Pager\\Pagination\\PaginationInterface' === $parameterType) { $knp = new \Knp\Component\Pager\Paginator(); $paginator = $knp->paginate($paginator->getQuery(), $page, $limitPerPage); } return $paginator; }