Commit 0854540b authored by gbyte.co's avatar gbyte.co

Improve hook_simple_sitemap_bundle_settings_alter logic

parent 83326511
......@@ -109,6 +109,13 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
if (!empty($bundle_settings['menu_link_content'])) {
foreach ($bundle_settings['menu_link_content'] as $bundle_name => $bundle_settings) {
// Skip this bundle if it is to be generated in a different sitemap variant.
if (NULL !== $this->sitemapVariant && isset($bundle_settings['variant'])
&& $bundle_settings['variant'] !== $this->sitemapVariant) {
$bundle_settings['index'] = 0;
}
unset($bundle_settings['variant']);
$bundle_context = [
'entity_type_id' => 'menu_link_content',
'bundle_name' => $bundle_name,
......@@ -116,12 +123,6 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
$sitemap_variant = $this->sitemapVariant;
$this->moduleHandler->alter('simple_sitemap_bundle_settings', $bundle_settings, $bundle_context, $sitemap_variant);
// Skip this bundle if it is to be generated in a different sitemap variant.
if (NULL !== $this->sitemapVariant && isset($bundle_settings['variant'])
&& $bundle_settings['variant'] !== $this->sitemapVariant) {
continue;
}
if ($bundle_settings['index']) {
$data_sets[] = $bundle_name;
}
......
......@@ -115,6 +115,13 @@ class EntityUrlGenerator extends UrlGeneratorBase {
foreach ($bundles as $bundle_name => $bundle_settings) {
// Skip this bundle if it is to be generated in a different sitemap variant.
if (NULL !== $this->sitemapVariant && isset($bundle_settings['variant'])
&& $bundle_settings['variant'] !== $this->sitemapVariant) {
$bundle_settings['index'] = 0;
}
unset($bundle_settings['variant']);
$bundle_context = [
'entity_type_id' => $entity_type_name,
'bundle_name' => $bundle_name,
......@@ -122,12 +129,6 @@ class EntityUrlGenerator extends UrlGeneratorBase {
$sitemap_variant = $this->sitemapVariant;
$this->moduleHandler->alter('simple_sitemap_bundle_settings', $bundle_settings, $bundle_context, $sitemap_variant);
// Skip this bundle if it is to be generated in a different sitemap variant.
if (NULL !== $this->sitemapVariant && isset($bundle_settings['variant'])
&& $bundle_settings['variant'] !== $this->sitemapVariant) {
continue;
}
if ($bundle_settings['index']) {
$data_sets[] = [
'bundle_settings' => $bundle_settings,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment