ardiakov/simple-pagination

There is no license information available for the latest version (1.1) of this package.

Simple pagination class

1.1 2021-06-22 13:15 UTC

This package is not auto-updated.

Last update: 2024-06-05 03:44:49 UTC


README

Пример использования пагинации на примере doctrine/orm

    $perPage     = 20;
    $currentPage = (int) $request->query->get('page', 1);

    $qb         = $this->repository->paginationQuery();
    $pagination = new Paginator($perPage, $currentPage, new DoctrineOrmDataProvider($qb));

    return [
        'list'        => $pagination->result(),
        'currentPage' => $currentPage,
        'pages'       => $pagination->pages(),
        'totalResult' => $pagination->countResult(),
    ];

Подключение twig шаблона

   # app/config/config.yml
   twig:
       # ...
       paths:
           '%kernel.project_dir%/vendor/ardiakov/simple-pagination/src/resources/templates': simple-pagination

Вывести шаблон в нужном месте

    {% include '@simple-pagination/_pagination.html.twig' with {
        'routeName': 'worki_vacancy_list',
        'routeParameters': {}
    } %}