Skip to content
Snippets Groups Projects

Add OverrideSitemapRendererEvent

Merged Matthias Adrowski requested to merge feature_customRenderer into master
All threads resolved!
Files
20
@@ -60,12 +60,16 @@ class GenerateSitemapCommandController extends Command {
public function configure(): void {
$this->setDescription('Generate the sitemap XML files')
->addArgument(
'relativePathToSitemap', InputArgument::OPTIONAL,
'The relative path to the sitemap files, leave empty for web root', ''
'relativePathToSitemap',
InputArgument::OPTIONAL,
'The relative path to the sitemap files, leave empty for web root',
''
)
->addArgument('siteRootId', InputArgument::OPTIONAL, 'The id of the root page to start the sitemap from', 1)
->addArgument(
'enableFilter', InputArgument::OPTIONAL, 'Don\'t add hidden pages to the result (NOT "NOT_IN_MENU"!)',
'enableFilter',
InputArgument::OPTIONAL,
'Don\'t add hidden pages to the result (NOT "NOT_IN_MENU"!)',
TRUE
);
}
@@ -100,8 +104,13 @@ class GenerateSitemapCommandController extends Command {
foreach ($typoScriptConfiguration['plugin']['tx_seo']['config'] as $sitemapName => $sitemapConfig) {
$xslPath = PagesSitemapGenerator::getXslFilePath($typoScriptConfiguration, $sitemapName);
$this->writeSitemaps(
$sitemapName, $languages, $defaultLanguage,
$relativePathToSitemap, $siteRootId, $enableFilter, $xslPath
$sitemapName,
$languages,
$defaultLanguage,
$relativePathToSitemap,
$siteRootId,
$enableFilter,
$xslPath
);
$this->writeSitemapIndex($xslPath, $relativePathToSitemap, $sitemapName, $siteBaseUrl);
}
@@ -128,7 +137,8 @@ class GenerateSitemapCommandController extends Command {
if ($siteRootId > 0) {
// Get the rootline for the current page
$rootline = GeneralUtility::makeInstance(
RootlineUtility::class, $siteRootId
RootlineUtility::class,
$siteRootId
)->get();
}
@@ -157,8 +167,13 @@ class GenerateSitemapCommandController extends Command {
* @throws \Doctrine\DBAL\Driver\Exception
*/
protected function writeSitemaps(
string $sitemapName, array $languages,
SiteLanguage $defaultLanguage, string $relativePathToSitemap, int $siteRootId, $enableFilter, string $xslPath
string $sitemapName,
array $languages,
SiteLanguage $defaultLanguage,
string $relativePathToSitemap,
int $siteRootId,
$enableFilter,
string $xslPath
) {
$sitemapFileNamePart = $this->getSitemapFilenameBySitemapName($sitemapName);
$directoryToSitemap = Environment::getPublicPath() . $relativePathToSitemap;
@@ -175,7 +190,6 @@ class GenerateSitemapCommandController extends Command {
$enableFilter,
$xslPath
);
$sitemapGenerator->setXslPath($xslPath);
$sitemapGenerator->setTypoScriptConfiguration($this->getTypoScriptConfiguration($siteRootId));
$sitemapEntryPages = array_chunk(
$sitemapGenerator->getSitemapEntries($sitemapName),
@@ -204,7 +218,10 @@ class GenerateSitemapCommandController extends Command {
* @param string $siteBaseUrl
*/
protected function writeSitemapIndex(
string $xslPath, string $relativePathToSitemap, string $sitemapName, string $siteBaseUrl
string $xslPath,
string $relativePathToSitemap,
string $sitemapName,
string $siteBaseUrl
): void {
// start writing index sitemap
// we hardcode http:// as protocol because of the Sitemap.xsl from TYPO3 who have it hardcoded
Loading