Commit 83326511 authored by gbyte's avatar gbyte

Improve hook_simple_sitemap_bundle_settings_alter logic

parent d4b538da
...@@ -166,11 +166,11 @@ function hook_simple_sitemap_variants_alter(array &$variants) { ...@@ -166,11 +166,11 @@ function hook_simple_sitemap_variants_alter(array &$variants) {
} }
/** /**
* @param $bundle_settings * @param array $bundle_settings
* @param $entity_type_id * @param array $bundle_context
* @param $bundle_name * @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 { ...@@ -106,20 +106,23 @@ class EntityMenuLinkContentUrlGenerator extends UrlGeneratorBase {
public function getDataSets() { public function getDataSets() {
$data_sets = []; $data_sets = [];
$bundle_settings = $this->generator->getBundleSettings(); $bundle_settings = $this->generator->getBundleSettings();
$entity_type_name = 'menu_link_content'; if (!empty($bundle_settings['menu_link_content'])) {
if (!empty($bundle_settings[$entity_type_name])) { foreach ($bundle_settings['menu_link_content'] as $bundle_name => $bundle_settings) {
foreach ($bundle_settings[$entity_type_name] as $bundle_name => $settings) {
$bundle_name_alterable = $bundle_name;
$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. // Skip this bundle if it is to be generated in a different sitemap variant.
if (NULL !== $this->sitemapVariant && isset($settings['variant']) if (NULL !== $this->sitemapVariant && isset($bundle_settings['variant'])
&& $settings['variant'] !== $this->sitemapVariant) { && $bundle_settings['variant'] !== $this->sitemapVariant) {
continue; continue;
} }
if ($settings['index']) { if ($bundle_settings['index']) {
$data_sets[] = $bundle_name; $data_sets[] = $bundle_name;
} }
} }
......
...@@ -113,11 +113,14 @@ class EntityUrlGenerator extends UrlGeneratorBase { ...@@ -113,11 +113,14 @@ class EntityUrlGenerator extends UrlGeneratorBase {
} }
} }
$entity_type_name_alterable = $entity_type_name;
foreach ($bundles as $bundle_name => $bundle_settings) { 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. // Skip this bundle if it is to be generated in a different sitemap variant.
if (NULL !== $this->sitemapVariant && isset($bundle_settings['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