function hook_menu_link_insert

You are here

7 system.api.php hook_menu_link_insert($link)
8 menu_link.api.php hook_menu_link_insert(\Drupal\menu_link\Entity\MenuLink $menu_link)

Inform modules that a menu link has been created.

This hook is used to notify modules that menu items have been created. Contributed modules may use the information to perform actions based on the information entered into the menu system.

Parameters

$link: Associative array defining a menu link as passed into menu_link_save().

See also

hook_menu_link_update()

hook_menu_link_delete()

Related topics

1 function implements hook_menu_link_insert()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

menu_test_menu_link_insert in modules/simpletest/tests/menu_test.module
Implements hook_menu_link_insert().

File

modules/system/system.api.php, line 1365
Hooks provided by Drupal core and the System module.

Code

function hook_menu_link_insert($link) {
  // In our sample case, we track menu items as editing sections
  // of the site. These are stored in our table as 'disabled' items.
  $record['mlid'] = $link['mlid'];
  $record['menu_name'] = $link['menu_name'];
  $record['status'] = 0;
  drupal_write_record('menu_example', $record);
}