function Menu::preDelete

Same name in other branches
  1. 8.9.x core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu::preDelete()
  2. 10 core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu::preDelete()
  3. 11.x core/modules/system/src/Entity/Menu.php \Drupal\system\Entity\Menu::preDelete()

Overrides ConfigEntityBase::preDelete

File

core/modules/system/src/Entity/Menu.php, line 86

Class

Menu
Defines the Menu configuration entity class.

Namespace

Drupal\system\Entity

Code

public static function preDelete(EntityStorageInterface $storage, array $entities) {
    parent::preDelete($storage, $entities);
    
    /** @var \Drupal\Core\Menu\MenuLinkManagerInterface $menu_link_manager */
    $menu_link_manager = \Drupal::service('plugin.manager.menu.link');
    foreach ($entities as $menu) {
        // Delete all links from the menu.
        $menu_link_manager->deleteLinksInMenu($menu->id());
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.