function MenuLinkContentHooks::menuDelete

Implements hook_ENTITY_TYPE_delete().

Attributes

#[Hook('menu_delete')]

File

core/modules/menu_link_content/src/Hook/MenuLinkContentHooks.php, line 61

Class

MenuLinkContentHooks
Hook implementations for menu_link_content.

Namespace

Drupal\menu_link_content\Hook

Code

public function menuDelete(MenuInterface $menu) : void {
  $storage = \Drupal::entityTypeManager()->getStorage('menu_link_content');
  $menu_links = $storage->loadByProperties([
    'menu_name' => $menu->id(),
  ]);
  $storage->delete($menu_links);
}

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