function hook_menu_delete

Respond to a custom menu deletion.

This hook is used to notify modules that a custom menu along with all links contained in it (if any) has been deleted. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters

$menu: An array representing a custom menu:

  • menu_name: The unique name of the custom menu.
  • title: The human readable menu title.
  • description: The custom menu description.

See also

hook_menu_insert()

hook_menu_update()

Related topics

4 functions implement hook_menu_delete()

Note: the procedural functions in this list are found by pattern matching, so the list may include some functions that are not actually implementations of this hook.

BlockHooks::menuDelete in core/modules/block/src/Hook/BlockHooks.php
Implements hook_ENTITY_TYPE_delete() for menu entities.
block_menu_delete in modules/block/block.module
Implements hook_menu_delete().
MenuLinkContentHooks::menuDelete in core/modules/menu_link_content/src/Hook/MenuLinkContentHooks.php
Implements hook_ENTITY_TYPE_delete().
MenuUiHooks::menuDelete in core/modules/menu_ui/src/Hook/MenuUiHooks.php
Implements hook_ENTITY_TYPE_delete().
1 invocation of hook_menu_delete()
menu_delete in modules/menu/menu.module
Delete a custom menu and all contained links.

File

modules/menu/menu.api.php, line 78

Code

function hook_menu_delete($menu) {
    // Delete the record from our variable.
    $my_menus = variable_get('my_module_menus', array());
    unset($my_menus[$menu['menu_name']]);
    variable_set('my_module_menus', $my_menus);
}

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