You are here

function menu_reset_item in Drupal 7

Same name and namespace in other branches
  1. 4 modules/menu.module \menu_reset_item()
  2. 5 modules/menu/menu.module \menu_reset_item()
  3. 6 modules/menu/menu.module \menu_reset_item()

Reset a system-defined menu link.

2 calls to menu_reset_item()
menu_delete_menu_confirm_submit in modules/menu/menu.admin.inc
Delete a custom menu and all links in it.
menu_reset_item_confirm_submit in modules/menu/menu.admin.inc
Process menu reset item form submissions.

File

modules/menu/menu.module, line 472
Allows administrators to customize the site's navigation menus.

Code

function menu_reset_item($link) {

  // To reset the link to its original values, we need to retrieve its
  // definition from hook_menu(). Otherwise, for example, the link's menu would
  // not be reset, because properties like the original 'menu_name' are not
  // stored anywhere else. Since resetting a link happens rarely and this is a
  // one-time operation, retrieving the full menu router does no harm.
  $menu = menu_get_router();
  $router_item = $menu[$link['router_path']];
  $new_link = _menu_link_build($router_item);

  // Merge existing menu link's ID and 'has_children' property.
  foreach (array(
    'mlid',
    'has_children',
  ) as $key) {
    $new_link[$key] = $link[$key];
  }
  menu_link_save($new_link);
  return $new_link;
}