PHP code example of swoopaholic / pagerfanta-bridge
1. Go to this page and download the library: Download swoopaholic/pagerfanta-bridge library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
swoopaholic / pagerfanta-bridge example snippets
php
/**
* Lists all entities.
*
* @Route("/", name="my_entities")
* @Method("GET")
* @Template()
*/
public function indexAction(Request $request)
{
$qb = $this->getDoctrine()->getManager()->createQueryBuilder('MyBundle:MyEntity');
$adapter = new \Pagerfanta\Adapter\DoctrineORMAdapter($qb);
$pager = new \Swoopaholic\Bridge\Pagerfanta\Pagerfanta($adapter);
$pager->setCurrentPage($request->get('page', 1));
$pager->setMaxPerPage(50);
return array(
'entities' => $pager->getData(),
'pagerfanta' => $pager->createView(),
);