facile-it / paginator-bundle
1.5
2017-12-21 10:04 UTC
Requires
- doctrine/orm: ^2.2.3
- symfony/framework-bundle: ^2.0 | ^3.0 | ^4.0
- twig/twig: ^1.5 | ^2.0
Requires (Dev)
- phpunit/phpunit: ^4.7 | ^5.0
- satooshi/php-coveralls: ~1.0
This package is not auto-updated.
Last update: 2023-06-04 08:46:24 UTC
README
轻量级的symfony2分页系统
要求
- 如果您计划包含twig模板,则需要Twig
>=1.5
版本。 - 允许使用Twig
2.*
特性
- 可以通过请求或通过setter进行初始化
- 处理路由以及路由参数
安装和配置
使用Composer非常简单,添加
{ "require": { "facile-it/paginator-bundle": "dev-master" } }
或者如果您想克隆仓库
git clone git://github.com/facile-it/paginator-bundle.git vendor/facile-it/PaginatorBundle
将PaginatorBundle添加到您的应用内核
// app/AppKernel.php public function registerBundles() { return array( // ... new Facile\PaginatorBundle\FacilePaginatorBundle(), // ... ); }
使用示例
控制器
当前分页器可以分页
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 ) );
视图
{# 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>