key = $key; $this->config = $config; $this->request = $request; if ($cObj === null) { $cObj = GeneralUtility::makeInstance(ContentObjectRenderer::class); } $this->cObj = $cObj; } /** * @return string */ public function getKey(): string { return $this->key; } /** * @return int */ public function getNumberOfPages(): int { return (int)ceil(count($this->items) / $this->numberOfItemsPerPage); } /** * @return int */ public function getLastModified(): int { $lastMod = 0; foreach ($this->items as $item) { if ((int)$item['lastMod'] > $lastMod) { $lastMod = (int)$item['lastMod']; } } return $lastMod; } /** * @param array $data * @return array */ protected function defineUrl(array $data): array { return $data; } /** * @return array */ public function getItems(): array { $pageNumber = (int)($this->request->getQueryParams()['page'] ?? 0); $page = $pageNumber > 0 ? $pageNumber : 0; $items = array_slice( $this->items, $page * $this->numberOfItemsPerPage, $this->numberOfItemsPerPage ); return array_map([$this, 'defineUrl'], $items); } }