Commit 83326511 authored by gbyte.co's avatar gbyte.co

Improve hook_simple_sitemap_bundle_settings_alter logic

parent d4b538da
......@@ -166,11 +166,11 @@ function hook_simple_sitemap_variants_alter(array &$variants) {
}
/**
* @param $bundle_settings
* @param $entity_type_id
* @param $bundle_name
* @param array $bundle_settings
* @param array $bundle_context
* @param string|null $sitemap_variant
*/
function hook_simple_sitemap_bundle_settings_alter(array &$bundle_settings, $entity_type_id, $bundle_name) {
function hook_simple_sitemap_bundle_settings_alter(array &$bundle_settings, $bundle_context, $sitemap_variant) {
}
......
......@@ -106,20 +106,23 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
public function getDataSets() {
$data_sets = [];
$bundle_settings = $this->generator->getBundleSettings();
$entity_type_name = 'menu_link_content';
if (!empty($bundle_settings[$entity_type_name])) {
foreach ($bundle_settings[$entity_type_name] as $bundle_name => $settings) {
$bundle_name_alterable = $bundle_name;
if (!empty($bundle_settings['menu_link_content'])) {
foreach ($bundle_settings['menu_link_content'] as $bundle_name => $bundle_settings) {
$this->moduleHandler->alter('simple_sitemap_bundle_settings', $settings, $entity_type_name, $bundle_name_alterable);
$bundle_context = [
'entity_type_id' => 'menu_link_content',
'bundle_name' => $bundle_name,
];
$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($settings['variant'])
&& $settings['variant'] !== $this->sitemapVariant) {
if (NULL !== $this->sitemapVariant && isset($bundle_settings['variant'])
&& $bundle_settings['variant'] !== $this->sitemapVariant) {
continue;
}
if ($settings['index']) {
if ($bundle_settings['index']) {
$data_sets[] = $bundle_name;
}
}
......
......@@ -113,11 +113,14 @@ class EntityUrlGenerator extends UrlGeneratorBase {
}
}
$entity_type_name_alterable = $entity_type_name;
foreach ($bundles as $bundle_name => $bundle_settings) {
$bundle_name_alterable = $bundle_name;
$this->moduleHandler->alter('simple_sitemap_bundle_settings', $bundle_settings, $entity_type_name_alterable, $bundle_name_alterable);
$bundle_context = [
'entity_type_id' => $entity_type_name,
'bundle_name' => $bundle_name,
];
$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'])
......
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