ns / filtered-pagination-bundle
此包提供了一个分页过滤处理程序
4.3.0
2022-10-06 05:05 UTC
Requires
- php: >=7.1
- knplabs/knp-paginator-bundle: ^2.4||^5.0||^6.0
- lexik/form-filter-bundle: ^4.0||^5.0||^6.0||^7.0
- liip/rmt: ^1.6
- symfony/event-dispatcher: ^4.0||^5.0||^6.0
- symfony/form: ^4.0||^5.0||^6.0
- symfony/framework-bundle: ^4.0||^5.0||^6.0
- symfony/http-foundation: ^4.0||^5.0||^6.0
Requires (Dev)
- phpunit/phpunit: ^7.0||^9.5
This package is auto-updated.
Last update: 2024-09-17 05:16:27 UTC
README
composer require ns/filtered-pagination-bundle
编辑AppKernel.php并添加该包
...
new Knp\Bundle\PaginatorBundle\KnpPaginatorBundle(),
new Lexik\Bundle\FormFilterBundle\LexikFormFilterBundle(),
new NS\FilteredPaginationBundle\NSFilteredPaginationBundle(),
使用方法
在一个控制器中,你请求过滤分页包。
$query = $this->get('doctrine.orm.entity_manager')->getRepository('...')->getSomeQuery();
$filteredPaginator = $this->get('ns.filtered_pagination');
list($form, $pagination, $redirect) = $filteredPaginator->process($request, $formType, $query, 'sessionKey');
if ($redirect) {
return $this->redirect($this->generateUrl('practiceUsers'));
}
限制选择
你可以使用提供的LimitSelectType提供一个每页“X”个结果的选项。如果你这样做,你应该包含处理每页数量变化的main.js资源。