From 8649db189df672d379d2c587f3ded86f177bc064 Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Fri, 9 Oct 2009 08:02:25 +0000 Subject: #473082 by sun, Amitaibu, dropcube, and Pasqualle: Added a custom menu API. --- modules/menu/menu.api.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 1 deletion(-) (limited to 'modules/menu/menu.api.php') diff --git a/modules/menu/menu.api.php b/modules/menu/menu.api.php index 80cd58df4..599a4a124 100644 --- a/modules/menu/menu.api.php +++ b/modules/menu/menu.api.php @@ -291,7 +291,7 @@ function hook_translated_menu_link_alter(&$item, $map) { } } - /** +/** * Inform modules that a menu link has been created. * * This hook is used to notify modules that menu items have been @@ -357,6 +357,78 @@ function hook_menu_link_delete($link) { ->execute(); } +/** + * Informs modules that a custom menu was created. + * + * This hook is used to notify modules that a custom menu has been created. + * Contributed modules may use the information to perform actions based on the + * information entered into the menu system. + * + * @param $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 hook_menu_update() + * @see hook_menu_delete() + */ +function hook_menu_insert($menu) { + // For example, we track available menus in a variable. + $my_menus = variable_get('my_module_menus', array()); + $my_menus[$menu['menu_name']] = $menu['menu_name']; + variable_set('my_module_menus', $my_menus); +} + +/** + * Informs modules that a custom menu was updated. + * + * This hook is used to notify modules that a custom menu has been updated. + * Contributed modules may use the information to perform actions based on the + * information entered into the menu system. + * + * @param $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: The current 'menu_name'. Note that internal menu names cannot + * be changed after initial creation. + * + * @see hook_menu_insert() + * @see hook_menu_delete() + */ +function hook_menu_update($menu) { + // For example, we track available menus in a variable. + $my_menus = variable_get('my_module_menus', array()); + $my_menus[$menu['menu_name']] = $menu['menu_name']; + variable_set('my_module_menus', $my_menus); +} + +/** + * Informs modules that a custom menu was deleted. + * + * 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. + * + * @param $link + * 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 hook_menu_insert() + * @see hook_menu_update() + */ +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); +} + /** * @} End of "addtogroup hooks". */ -- cgit v1.2.3