- Issue created by @lolgm
- Status changed to Needs review
5 months ago 10:12am 29 August 2024
When creating a new micro site with menu and the Simple XML sitemap module (simple_sitemap) in version 4.x, the following error occurs:
Error: Call to undefined method Drupal\simple_sitemap\Manager\Generator::setBundleSettings() in _micro_menu_generate_simple_sitemap_settings() (line 116 of modules/contrib/micro_menu/micro_menu.module).
micro_menu_site_insert(Object)
call_user_func_array(Object, Array) (Line: 416)
Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}(Object, 'micro_menu') (Line: 395)
Drupal\Core\Extension\ModuleHandler->invokeAllWith('site_insert', Object) (Line: 415)
Drupal\Core\Extension\ModuleHandler->invokeAll('site_insert', Array) (Line: 215)
Drupal\Core\Entity\EntityStorageBase->invokeHook('insert', Object) (Line: 900)
Drupal\Core\Entity\ContentEntityStorageBase->invokeHook('insert', Object) (Line: 564)
Drupal\Core\Entity\EntityStorageBase->doPostSave(Object, ) (Line: 781)
Drupal\Core\Entity\ContentEntityStorageBase->doPostSave(Object, ) (Line: 489)
Drupal\Core\Entity\EntityStorageBase->save(Object) (Line: 806)
Drupal\Core\Entity\Sql\SqlContentEntityStorage->save(Object) (Line: 354)
Drupal\Core\Entity\EntityBase->save() (Line: 293)
Drupal\Core\Entity\EntityForm->save(Array, Object) (Line: 349)
Drupal\micro_site\Form\SiteForm->save(Array, Object)
...
This problem occurs due to changes in the simple_sitemap API in version 4.x.
To solve this, we should change the simple_sitemap.generator
service to simple_sitemap.entity_manager
to get the expected behaviour.
function _micro_menu_generate_simple_sitemap_settings(MenuInterface $menu) {
...
/** @var \Drupal\simple_sitemap\Manager\EntityManager $entity_manager */
$entity_manager = \Drupal::service('simple_sitemap.entity_manager');
$entity_manager->setBundleSettings('menu_link_content', $menu->id(), $settings);
}
None.
None.
None.
None.
Needs review
1.0
Code