‪TYPO3CMS  10.4
ArrayPaginator.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 {
25  private ‪$items;
26 
30  private ‪$paginatedItems = [];
31 
32  public function ‪__construct(
33  array ‪$items,
34  int ‪$currentPageNumber = 1,
35  int ‪$itemsPerPage = 10
36  ) {
37  $this->items = ‪$items;
40 
41  $this->‪updateInternalState();
42  }
43 
47  public function ‪getPaginatedItems(): iterable
48  {
50  }
51 
52  protected function ‪updatePaginatedItems(int ‪$itemsPerPage, int $offset): void
53  {
54  $this->paginatedItems = array_slice($this->items, $offset, ‪$itemsPerPage);
55  }
56 
57  protected function ‪getTotalAmountOfItems(): int
58  {
59  return count($this->items);
60  }
61 
62  protected function ‪getAmountOfItemsOnCurrentPage(): int
63  {
64  return count($this->paginatedItems);
65  }
66 }
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\getAmountOfItemsOnCurrentPage
‪getAmountOfItemsOnCurrentPage()
Definition: ArrayPaginator.php:60
‪TYPO3\CMS\Core\Pagination\AbstractPaginator\setItemsPerPage
‪setItemsPerPage(int $itemsPerPage)
Definition: AbstractPaginator.php:157
‪TYPO3\CMS\Core\Pagination\AbstractPaginator\$itemsPerPage
‪int $itemsPerPage
Definition: AbstractPaginator.php:40
‪TYPO3\CMS\Core\Pagination
Definition: AbstractPaginator.php:18
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\$paginatedItems
‪array $paginatedItems
Definition: ArrayPaginator.php:28
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\$items
‪array $items
Definition: ArrayPaginator.php:24
‪TYPO3\CMS\Core\Pagination\AbstractPaginator\updateInternalState
‪updateInternalState()
Definition: AbstractPaginator.php:116
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\updatePaginatedItems
‪updatePaginatedItems(int $itemsPerPage, int $offset)
Definition: ArrayPaginator.php:50
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\getTotalAmountOfItems
‪getTotalAmountOfItems()
Definition: ArrayPaginator.php:55
‪TYPO3\CMS\Core\Pagination\AbstractPaginator
Definition: AbstractPaginator.php:21
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\__construct
‪__construct(array $items, int $currentPageNumber=1, int $itemsPerPage=10)
Definition: ArrayPaginator.php:30
‪TYPO3\CMS\Core\Pagination\ArrayPaginator
Definition: ArrayPaginator.php:21
‪TYPO3\CMS\Core\Pagination\ArrayPaginator\getPaginatedItems
‪iterable array getPaginatedItems()
Definition: ArrayPaginator.php:45
‪TYPO3\CMS\Core\Pagination\AbstractPaginator\$currentPageNumber
‪int $currentPageNumber
Definition: AbstractPaginator.php:36
‪TYPO3\CMS\Core\Pagination\AbstractPaginator\setCurrentPageNumber
‪setCurrentPageNumber(int $currentPageNumber)
Definition: AbstractPaginator.php:169