menu_save
- Versions
- 7
menu_save($menu)
Save a custom menu.
Modules should always pass a fully populated $menu when saving a custom menu, so other modules are able to output proper status or watchdog messages.
See also
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.
- old_name: For existing menus, the current 'menu_name', otherwise empty. Decides whether hook_menu_insert() or hook_menu_update() will be invoked.
Code
modules/menu/menu.module, line 238
<?php
function menu_save($menu) {
db_merge('menu_custom')
->key(array('menu_name' => $menu['menu_name']))
->fields(array(
'title' => $menu['title'],
'description' => $menu['description'],
))
->execute();
// Since custom menus are keyed by name and their machine-name cannot be
// changed, there is no real differentiation between inserting and updating a
// menu. To overcome this, we define the existing menu_name as 'old_name' in
// menu_edit_menu().
// @todo Replace this condition when db_merge() returns the proper query
// result (insert/update).
if (!empty($menu['old_name'])) {
module_invoke_all('menu_update', $menu);
}
else {
module_invoke_all('menu_insert', $menu);
}
}
?>Login or register to post comments 