function MenuLinkContentHooks::menuDelete

Same name and namespace in other branches
  1. 11.x core/modules/menu_link_content/src/Hook/MenuLinkContentHooks.php \Drupal\menu_link_content\Hook\MenuLinkContentHooks::menuDelete()

Implements hook_ENTITY_TYPE_delete().

Attributes

#[Hook('menu_delete')]

File

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

Class

MenuLinkContentHooks
Hook implementations for menu_link_content.

Namespace

Drupal\menu_link_content\Hook

Code

public function menuDelete(MenuInterface $menu) : void {
  $storage = $this->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.