generateItems(); } protected function generateItems(): void { $pageRepository = GeneralUtility::makeInstance(PageRepository::class); $pages = $pageRepository->getPagesOverlay($this->getPages()); $languageAspect = $this->getCurrentLanguageAspect(); foreach ($pages as $page) { if (!$pageRepository->isPageSuitableForLanguage($page, $languageAspect)) { continue; } $this->items[] = $page + [ 'lastMod' => (int)($page['SYS_LASTCHANGED'] ?: $page['tstamp']), 'changefreq' => $page['sitemap_changefreq'], 'priority' => (float)$page['sitemap_priority'], ]; } } protected function getPages(): array { if (!empty($this->config['rootPage'])) { $rootPageId = (int)$this->config['rootPage']; } else { $site = $this->request->getAttribute('site'); $rootPageId = $site->getRootPageId(); } $excludePagesRecursive = GeneralUtility::intExplode(',', (string)($this->config['excludePagesRecursive'] ?? ''), true); $pageRepository = GeneralUtility::makeInstance(PageRepository::class); $pageIds = $pageRepository->getDescendantPageIdsRecursive($rootPageId, 99, 0, $excludePagesRecursive); $pageIds = array_merge([$rootPageId], $pageIds); $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class) ->getQueryBuilderForTable('pages'); $constraints = [ $queryBuilder->expr()->in('uid', $pageIds), ]; if (!empty($this->config['additionalWhere'])) { $constraints[] = QueryHelper::quoteDatabaseIdentifiers($queryBuilder->getConnection(), QueryHelper::stripLogicalOperatorPrefix($this->config['additionalWhere'])); } if (!empty($this->config['excludedDoktypes'])) { $excludedDoktypes = GeneralUtility::intExplode(',', (string)$this->config['excludedDoktypes']); if (!empty($excludedDoktypes)) { $constraints[] = $queryBuilder->expr()->notIn('doktype', implode(',', $excludedDoktypes)); } } $pages = $queryBuilder->select('*') ->from('pages') ->where(...$constraints) ->orderBy('uid', 'ASC') ->executeQuery() ->fetchAllAssociative(); return $pages; } protected function getCurrentLanguageAspect(): LanguageAspect { return GeneralUtility::makeInstance(Context::class)->getAspect('language'); } protected function defineUrl(array $data): array { $typoLinkConfig = [ 'page' => GeneralUtility::makeInstance(RecordFactory::class)->createFromDatabaseRow('pages', $data), 'parameter' => $data['uid'], 'forceAbsoluteUrl' => 1, ]; $data['loc'] = $this->cObj->createUrl($typoLinkConfig); return $data; } }