Download the PHP package arturdoruch/list-bundle without Composer
On this page you can find all versions of the php package arturdoruch/list-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download arturdoruch/list-bundle
More information about arturdoruch/list-bundle
Files in arturdoruch/list-bundle
Package list-bundle
Short Description Symfony package for pagination, sorting and filtering of a list items.
License MIT
Informations about the package list-bundle
ListBundle
Symfony bundle for pagination, sorting and filtering of list items.
Bundle contains paginators supporting:
- array
- Doctrine\ORM\Query
- Doctrine\ORM\QueryBuilder
- Doctrine\ODM\MongoDB\Query\Query
- Doctrine\ODM\MongoDB\Query\Builder
- Doctrine\MongoDB\CursorInterface
- MongoCursor
For other database queries or cursors you can create own paginators. See paginators configuration option.
Installation
Run composer command
and register list-bundle and required other bundles in application Kernel class.
In Symfony 3
In Symfony >= 4
JavaScript support
For JavaScript support install (with yarn
or npm
) package @arturdoruch/list.
Package contains also file with CSS styles, styling the filter form and item list.
Bundle configuration
See bundle configuration options.
Usage
In short:
- Create controller action getting the item list
- Create template displaying item list
Controller
Creating controller action getting the item list
The controller action requirements:
- The route method must be type of
GET
. - To the twig template must be passed the
ArturDoruch\ListBundle\ItemList
object.
Full example of the controller action getting book list:
Pagination item limits
The default limits of list items displayed per page are specified in bundle configuration
at path pagination.item_limits.
To setting different item limits for a specific list call ArturDoruch\ListBundle\Pagination::setItemLimits()
method
with a custom values.
Example:
Filter form
In order to filtering list items, you must create FormType
class.
- You can use the
ArturDoruch\ListBundle\Form\FilterType
class and add the custom filter fields to the form in controller, - or create own form type class and (optionally) extend the
ArturDoruch\ListBundle\Form\FilterType
class.
The filter form must have method type of GET
and csrf_protection
option should be set to false.
Created FormType
class pass in the constructor of the ArturDoruch\ListBundle\ItemList
object.
Example of the filter form type class:
Sort choice collection
If you want to render an HTML "select" field with sorting options create ArturDoruch\ListBundle\Sorting\SortChoiceCollection
object and specify the sorting choices. Then pass the SortChoiceCollection
object in the constructor
of the ArturDoruch\ListBundle\ItemList
object.
This is an alternative for sorting links rendered in twig template with arturdoruch_list_sort_link
function.
Example:
View
Twig functions
See Twig functions rendering the list components.
Creating template displaying item list
Template for use with AJAX request.
Example of template displaying all of the list components.
All versions of list-bundle with dependencies
symfony/framework-bundle Version ^3.3|^4.0|^5.0
symfony/form Version ^3.3|^4.0|^5.0
symfony/yaml Version ^3.3|^4.0|^5.0
symfony/twig-bundle Version ^3.3|^4.0|^5.0