2017 © Pedro Peláez
 

symfony-bundle kr-paginator-bundle

Basic Paginator bundle for Symfony2

image

kr/kr-paginator-bundle

Basic Paginator bundle for Symfony2

  • Friday, December 11, 2015
  • by ekaterir
  • Repository
  • 1 Watchers
  • 0 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

About KRPaginatorBundle

This is a simple bundle with 5 types of pagers (same as DataTables):, (*1)

  • simple - Next and Previous buttons;
  • numbers - Number buttons;
  • simple_numbers - Next, Previous, and Number buttons;
  • full - First, Next, Previous, Last buttons;
  • full_numbers - First, Next, Previous, Last, and Number buttons.

No configurations are necessary., (*2)

Usage

In the controller

<?php
// Acme/Bundle/Controller/DefaultController.php

// ...

public function indexAction()
{
    $count = $repository->getAllUsersCount();

    $paginator = $this->get('kr_paginator')->buildPaginator('simple_numbers', [
        'totalItems'    => $count,  // required
        'limit'     => 5,       // optional (default is 10)
        'queryKey'  => 'p',     // optional (default is 'page')
        'adjacentCount' => 3        // optional (default is 2)
    ]);

    $limit = $paginator->getLimit();
    $offset = $paginator->getOffset();

    $results = $repository->getAllUsers($limit, $offset);

    return $this->render('Bundle:Default:index.html.twig', [
        'results'   => $results,
        'paginator'     => $paginator->render()
    ]);
}

In the view


{{ paginator|raw }}
    {% for result in results %}
  • {{ result.name }}
  • {% endfor %}

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*3)

$ composer require kr/kr-paginator-bundle "dev-master"

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*4)

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*5)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...

            new KR\PaginatorBundle\KRPaginatorBundle(),
        );

        // ...
    }

    // ...
}

The Versions

11/12 2015

dev-master

9999999-dev

Basic Paginator bundle for Symfony2

  Sources   Download

MIT