function hook_menu_link_update

Inform modules that a menu link has been updated.

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

Parameters

\Drupal\menu_link\Plugin\Core\Entity\MenuLink $menu_link: A menu link entity.

See also

hook_menu_link_presave()

hook_menu_link_insert()

hook_menu_link_delete()

Related topics

1 function implements hook_menu_link_update()

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_update in drupal/core/modules/system/tests/modules/menu_test/menu_test.module
Implements hook_menu_link_update().

File

drupal/core/modules/menu_link/menu_link.api.php, line 104
Hooks provided by the Menu link module.

Code

function hook_menu_link_update(\Drupal\menu_link\Plugin\Core\Entity\MenuLink $menu_link) {

  // If the parent menu has changed, update our record.
  $menu_name = db_query("SELECT menu_name FROM {menu_example} WHERE mlid = :mlid", array(
    ':mlid' => $menu_link
      ->id(),
  ))
    ->fetchField();
  if ($menu_name != $menu_link->menu_name) {
    db_update('menu_example')
      ->fields(array(
      'menu_name' => $menu_link->menu_name,
    ))
      ->condition('mlid', $menu_link
      ->id())
      ->execute();
  }
}