By bbu23 on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
4.1.x
Introduced in version:
4.1.0
Issue links:
Description:
Description
The MenuImportEvent has been enhanced to include the menu machine name as a parameter. Event subscribers can now access the target menu name during import operations.
What changed
Previously, the MenuImportEvent only provided access to the menu item data. Now it also includes the menu name being imported.
Before (4.0.x)
use Drupal\menu_migration\Event\MenuImportEvent;
public function onMenuImport(MenuImportEvent $event) {
$menuItem = $event->getMenuItem();
// Menu name was not accessible
}
After (4.1.0+)
<?php
use Drupal\menu_migration\Event\MenuImportEvent;
public function onMenuImport(MenuImportEvent $event) {
$menuItem = $event->getMenuItem();
$menuName = $event->getMenuName(); // New method
// Now you can perform menu-specific logic
if ($menuName === 'main') {
// Handle main menu imports differently
}
}
Impacts:
Module developers