facile-it/paginator-bundle

This package is abandoned and no longer maintained. The author suggests using the knplabs/knp-paginator-bundle package instead.

lightweight symfony2 pagination

Installs: 4 559

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 45

Forks: 1

Open Issues: 0

Type:symfony-bundle

1.5 2017-12-21 10:04 UTC

README

A lightweight symfony2 pagination system

Build Status Code Climate

Requirements:

  • Twig>=1.5 version is required if you plan to include the twig template.
  • Twig 2.* is allowed

Features:

  • Inizialization can be made via request or via setters
  • Handle route as well as route parameters

Installation and configuration:

Quite easy Composer, add:

{
    "require": {
        "facile-it/paginator-bundle": "dev-master"
    }
}

Or if you want to clone the repos:

git clone git://github.com/facile-it/paginator-bundle.git vendor/facile-it/PaginatorBundle

Add PaginatorBundle to your application kernel

// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new Facile\PaginatorBundle\FacilePaginatorBundle(),
        // ...
    );
}

Usage examples:

Controller

Currently paginator can paginate:

  • Doctrine\ORM\QueryBuilder
// Acme\MainBundle\Controller\ProductController.php


    $queryBuilder = $this
        ->get('doctrine.orm.entity_manager')
        ->getRepository('AcmeMainBundle:Product')
        ->createQueryBuilder('product')

    $paginator = $this->get('facile.paginator')->parseRequest($this->getRequest());

    return $this->render('AcmeMainBundle:Product:list.html.twig', array(
        'results' => $pagination,
        'paginationInfo' => $paginator->getPaginationInfo($filterBuilder
        )
    );

View

{# display results #}
<table>
    {% for product in results %}
        <tr >
            <td>{{ product.id }}</td>
            <td>{{ product.title }}</td>
        </tr>
    {% endfor %}
</table>

{# display navigation #}
<div class="navigation">
    {% include 'FacilePaginatorBundle:Pagination:template.html.twig' %}
</div>