1 | <?php |
||
18 | class PaginationFactory |
||
19 | { |
||
20 | /** |
||
21 | * @var ObjectManagerInterface |
||
22 | */ |
||
23 | public $objectManager; |
||
24 | |||
25 | /** |
||
26 | * @var UrlGeneratorInterface |
||
27 | */ |
||
28 | public $urlGenerator; |
||
29 | |||
30 | /** |
||
31 | * @var RequestStack |
||
32 | */ |
||
33 | private $requestStack; |
||
34 | |||
35 | /** |
||
36 | * @var string |
||
37 | */ |
||
38 | private $pagerStrategy; |
||
39 | |||
40 | /** |
||
41 | * PaginationFactory constructor. |
||
42 | * |
||
43 | * @param UrlGeneratorInterface $urlGenerator |
||
44 | * @param ObjectManagerInterface $objectManager |
||
45 | * @param RequestStack $requestStack |
||
46 | * @param string $pagerStrategy |
||
47 | */ |
||
48 | public function __construct( |
||
59 | |||
60 | /** |
||
61 | * Get a paginated representation of a collection of entities. |
||
62 | * Your repository for the object $className must implement the 'findAllSorted' method |
||
63 | * @param string $className |
||
64 | * |
||
65 | * @return PaginatedRepresentation |
||
66 | */ |
||
67 | public function getRepresentation($className) |
||
95 | |||
96 | /** |
||
97 | * @param string $pagerStrategy |
||
98 | */ |
||
99 | public function setPagerStrategy($pagerStrategy) |
||
111 | |||
112 | /** |
||
113 | * @param array $results |
||
114 | * |
||
115 | * @return AdapterInterface |
||
116 | */ |
||
117 | private function getPagerAdapter($results) |
||
123 | |||
124 | /** |
||
125 | * Get the pagination parameters, filtered. |
||
126 | * |
||
127 | * @return array |
||
128 | */ |
||
129 | private function addPaginationParams() |
||
157 | |||
158 | /** |
||
159 | * Return the url of a resource based on the 'get_entity' route name convention. |
||
160 | * |
||
161 | * @param string $name |
||
162 | * @param $limit |
||
163 | * @param $page |
||
164 | * @param $sorting |
||
165 | * |
||
166 | * @return string |
||
167 | */ |
||
168 | private function getPaginatedRoute($name, $limit, $page, $sorting) |
||
179 | } |
||
180 |