|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Symfony\Component\DependencyInjection\Loader\Configurator; |
| 4 | + |
| 5 | +use Knp\Bundle\PaginatorBundle\Helper\Processor; |
| 6 | +use Knp\Bundle\PaginatorBundle\Subscriber\SlidingPaginationSubscriber; |
| 7 | +use Knp\Bundle\PaginatorBundle\Twig\Extension\PaginationExtension; |
| 8 | +use Knp\Bundle\PaginatorBundle\Twig\Extension\PaginationRuntime; |
| 9 | +use Knp\Component\Pager\ArgumentAccess\ArgumentAccessInterface; |
| 10 | +use Knp\Component\Pager\ArgumentAccess\RequestArgumentAccess; |
| 11 | +use Knp\Component\Pager\Event\Subscriber\Filtration\FiltrationSubscriber; |
| 12 | +use Knp\Component\Pager\Event\Subscriber\Paginate\PaginationSubscriber; |
| 13 | +use Knp\Component\Pager\Event\Subscriber\Sortable\SortableSubscriber; |
| 14 | +use Knp\Component\Pager\Paginator; |
| 15 | +use Knp\Component\Pager\PaginatorInterface; |
| 16 | + |
| 17 | +return static function (ContainerConfigurator $configurator): void { |
| 18 | + $services = $configurator->services(); |
| 19 | + |
| 20 | + $services |
| 21 | + ->set('knp_paginator', Paginator::class) |
| 22 | + ->public() |
| 23 | + ->lazy() |
| 24 | + ->args([ |
| 25 | + service('event_dispatcher'), |
| 26 | + service(ArgumentAccessInterface::class), |
| 27 | + service('database_connection')->nullOnInvalid(), |
| 28 | + ]) |
| 29 | + ->tag('proxy', ['interface' => PaginatorInterface::class]) |
| 30 | + ; |
| 31 | + |
| 32 | + $services->alias(PaginatorInterface::class, 'knp_paginator'); |
| 33 | + |
| 34 | + $services |
| 35 | + ->set(RequestArgumentAccess::class) |
| 36 | + ->args([service('request_stack')]) |
| 37 | + ; |
| 38 | + |
| 39 | + $services->alias(ArgumentAccessInterface::class, RequestArgumentAccess::class); |
| 40 | + |
| 41 | + $services |
| 42 | + ->set('knp_paginator.subscriber.paginate', PaginationSubscriber::class) |
| 43 | + ->tag('kernel.event_subscriber') |
| 44 | + ; |
| 45 | + |
| 46 | + $services |
| 47 | + ->set('knp_paginator.subscriber.sortable', SortableSubscriber::class) |
| 48 | + ->tag('kernel.event_subscriber') |
| 49 | + ; |
| 50 | + |
| 51 | + $services |
| 52 | + ->set('knp_paginator.subscriber.filtration', FiltrationSubscriber::class) |
| 53 | + ->tag('kernel.event_subscriber') |
| 54 | + ; |
| 55 | + |
| 56 | + $services->set('knp_paginator.subscriber.sliding_pagination', SlidingPaginationSubscriber::class) |
| 57 | + ->arg(0, [ |
| 58 | + 'defaultPaginationTemplate' => '%knp_paginator.template.pagination%', |
| 59 | + 'defaultRelLinksTemplate' => '%knp_paginator.template.rel_links%', |
| 60 | + 'defaultSortableTemplate' => '%knp_paginator.template.sortable%', |
| 61 | + 'defaultFiltrationTemplate' => '%knp_paginator.template.filtration%', |
| 62 | + 'defaultPageRange' => '%knp_paginator.page_range%', |
| 63 | + 'defaultPageLimit' => '%knp_paginator.page_limit%', |
| 64 | + ]) |
| 65 | + ->tag('kernel.event_subscriber') |
| 66 | + ->tag('kernel.event_listener', ['event' => 'kernel.request', 'method' => 'onKernelRequest']) |
| 67 | + ; |
| 68 | + |
| 69 | + $services |
| 70 | + ->set('knp_paginator.helper.processor', Processor::class) |
| 71 | + ->args([ |
| 72 | + service('router'), |
| 73 | + service('translator')->nullOnInvalid(), |
| 74 | + ]) |
| 75 | + ; |
| 76 | + |
| 77 | + $services |
| 78 | + ->set('knp_paginator.twig.extension.pagination', PaginationExtension::class) |
| 79 | + ->tag('twig.extension') |
| 80 | + ; |
| 81 | + |
| 82 | + $services |
| 83 | + ->set(PaginationRuntime::class) |
| 84 | + ->args([ |
| 85 | + service('knp_paginator.helper.processor'), |
| 86 | + param('knp_paginator.page_name'), |
| 87 | + param('knp_paginator.remove_first_page_param'), |
| 88 | + ]) |
| 89 | + ->tag('twig.runtime') |
| 90 | + ; |
| 91 | +}; |
0 commit comments