|
17 | 17 | use Extcode\CartProducts\Domain\Repository\CategoryRepository; |
18 | 18 | use Extcode\CartProducts\Domain\Repository\Product\ProductRepository; |
19 | 19 | use Psr\Http\Message\ResponseInterface; |
20 | | -use TYPO3\CMS\Core\Pagination\SimplePagination; |
| 20 | +use TYPO3\CMS\Core\Pagination\SlidingWindowPagination; |
21 | 21 | use TYPO3\CMS\Core\TypoScript\TypoScriptService; |
22 | 22 | use TYPO3\CMS\Core\Utility\GeneralUtility; |
23 | 23 | use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; |
@@ -154,19 +154,20 @@ public function listAction(int $currentPage = 1): ResponseInterface |
154 | 154 | $demand = $this->createDemandObjectFromSettings($this->settings); |
155 | 155 | $demand->setActionAndClass(__METHOD__, self::class); |
156 | 156 |
|
157 | | - $itemsPerPage = $this->settings['itemsPerPage'] ?? 20; |
| 157 | + $itemsPerPage = (int)($this->settings['itemsPerPage'] ?? 20); |
| 158 | + $maximumNumberOfLinks = (int)($this->settings['maximumNumberOfLinks'] ?? 0); |
158 | 159 |
|
159 | 160 | $products = $this->productRepository->findDemanded($demand); |
160 | | - $arrayPaginator = new QueryResultPaginator( |
| 161 | + $paginator = new QueryResultPaginator( |
161 | 162 | $products, |
162 | 163 | $currentPage, |
163 | 164 | $itemsPerPage |
164 | 165 | ); |
165 | | - $pagination = new SimplePagination($arrayPaginator); |
| 166 | + $pagination = new SlidingWindowPagination($paginator, $maximumNumberOfLinks); |
166 | 167 | $this->view->assignMultiple( |
167 | 168 | [ |
168 | 169 | 'products' => $products, |
169 | | - 'paginator' => $arrayPaginator, |
| 170 | + 'paginator' => $paginator, |
170 | 171 | 'pagination' => $pagination, |
171 | 172 | 'pages' => range(1, $pagination->getLastPageNumber()), |
172 | 173 | ] |
|
0 commit comments