如何为Symfony 4配置KnpPaginatorBundle

如何为Symfony 4配置KnpPaginatorBundle,symfony,symfony4,knppaginator,Symfony,Symfony4,Knppaginator,我希望将KnpPaginatorBundle实现到symfony4中 我这里的问题是,在他们的文档(针对S3)中,他们建议使用以下参数i config.yml knp_paginator: page_range: 5 # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see

我希望将KnpPaginatorBundle实现到symfony4中

我这里的问题是,在他们的文档(针对S3)中,他们建议使用以下参数i config.yml

knp_paginator:
page_range: 5                       # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6)
default_options:                                 
    page_name: page                 # page query parameter name
    sort_field_name: sort           # sort field query parameter name
    sort_direction_name: direction  # sort direction query parameter name
    distinct: true                  # ensure distinct results, useful when ORM queries are using GROUP BY statements
    filter_field_name: filterField  # filter field query parameter name
    filter_value_name: filterValue  # filter value query parameter name
template:                                        
    pagination: '@KnpPaginator/Pagination/sliding.html.twig'     # sliding pagination controls template                                    
    sortable: '@KnpPaginator/Pagination/sortable_link.html.twig' # sort link template                                
    filtration: '@KnpPaginator/Pagination/filtration.html.twig'  # filters template
我不确定在哪里使用这些参数,因为S4没有config.yml文件。 我找不到关于KNP包和S4的任何文档。非常感谢您的帮助!谢谢

在讨论symfony4问题之后,配置似乎是相同的:

他将配置放在“config/packages/paginator.yaml”中


因此,放置配置的位置是“config/packages/paginator.yaml”,为了清晰起见,“paginator.yaml”也可以是“knp_paginator.yaml”。
# config/packages/paginator.yaml
knp_paginator:
    page_range: 5                       # number of links showed in the pagination menu (e.g: you have 10 pages, a page_range of 3, on the 5th page you'll see links to page 4, 5, 6)
    default_options:
        page_name: page                 # page query parameter name
        sort_field_name: sort           # sort field query parameter name
        sort_direction_name: direction  # sort direction query parameter name
        distinct: true                  # ensure distinct results, useful when ORM queries are using GROUP BY statements
        filter_field_name: filterField  # filter field query parameter name
        filter_value_name: filterValue  # filter value query paameter name
    template:
        pagination: '@KnpPaginator/Pagination/sliding.html.twig'     # sliding pagination controls template
        sortable: '@KnpPaginator/Pagination/sortable_link.html.twig' # sort link template
        filtration: '@KnpPaginator/Pagination/filtration.html.twig'  # filters template