An open API service indexing awesome lists of open source software.

https://github.com/augustomoita/mottapgbundle

Pagination bundle for Symfony
https://github.com/augustomoita/mottapgbundle

actions bootstrap4 excel export pagination pdf php symfony-bundle symfony3

Last synced: 6 months ago
JSON representation

Pagination bundle for Symfony

Awesome Lists containing this project

README

          

# MottaPgBundle
---
#### Installation
- Add via composer
```console
$ composer require agusmoita/mottapg-bundle
```

#### Usage
- Controller
```php
use MottaPgBundle\Util\Paginator\Paginator;

/**
* @Route("/", name="person_index", methods={"GET|POST"})
*/
public function indexAction(Paginator $pg, PersonRepository $repo)
{
return $pg
->setView('person/index.html.twig')
->paginate($repo);
}
```

- Repository
```php
// PersonRepository.php

public function buildQuery($query, $pg)
{
// return SELECT a FROM AppBundle:Person a
return $query;
}
```

- View
```twig
{# person/index.html.twig #}

{% extends '@MottaPg/Paginator/table.html.twig' %}

{% block title %}

List of People


{% endblock %}

{% block paginator_table_header %}
First Name
Last Name
Birthday
{% endblock %}

{% block paginator_table_data %}
{{ entity.firstName }}
{{ entity.lastName }}
{{ entity.birthday|date('m-d-Y') }}
{% endblock %}
```

#### License
[MIT License](LICENSE)