menu.api.php

Hooks provided by the Menu module.

File

drupal/modules/menu/menu.api.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Menu module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Respond to a custom menu creation.
  12. *
  13. * This hook is used to notify modules that a custom menu has been created.
  14. * Contributed modules may use the information to perform actions based on the
  15. * information entered into the menu system.
  16. *
  17. * @param $menu
  18. * An array representing a custom menu:
  19. * - menu_name: The unique name of the custom menu.
  20. * - title: The human readable menu title.
  21. * - description: The custom menu description.
  22. *
  23. * @see hook_menu_update()
  24. * @see hook_menu_delete()
  25. */
  26. function hook_menu_insert($menu) {
  27. // For example, we track available menus in a variable.
  28. $my_menus = variable_get('my_module_menus', array());
  29. $my_menus[$menu['menu_name']] = $menu['menu_name'];
  30. variable_set('my_module_menus', $my_menus);
  31. }
  32. /**
  33. * Respond to a custom menu update.
  34. *
  35. * This hook is used to notify modules that a custom menu has been updated.
  36. * Contributed modules may use the information to perform actions based on the
  37. * information entered into the menu system.
  38. *
  39. * @param $menu
  40. * An array representing a custom menu:
  41. * - menu_name: The unique name of the custom menu.
  42. * - title: The human readable menu title.
  43. * - description: The custom menu description.
  44. * - old_name: The current 'menu_name'. Note that internal menu names cannot
  45. * be changed after initial creation.
  46. *
  47. * @see hook_menu_insert()
  48. * @see hook_menu_delete()
  49. */
  50. function hook_menu_update($menu) {
  51. // For example, we track available menus in a variable.
  52. $my_menus = variable_get('my_module_menus', array());
  53. $my_menus[$menu['menu_name']] = $menu['menu_name'];
  54. variable_set('my_module_menus', $my_menus);
  55. }
  56. /**
  57. * Respond to a custom menu deletion.
  58. *
  59. * This hook is used to notify modules that a custom menu along with all links
  60. * contained in it (if any) has been deleted. Contributed modules may use the
  61. * information to perform actions based on the information entered into the menu
  62. * system.
  63. *
  64. * @param $menu
  65. * An array representing a custom menu:
  66. * - menu_name: The unique name of the custom menu.
  67. * - title: The human readable menu title.
  68. * - description: The custom menu description.
  69. *
  70. * @see hook_menu_insert()
  71. * @see hook_menu_update()
  72. */
  73. function hook_menu_delete($menu) {
  74. // Delete the record from our variable.
  75. $my_menus = variable_get('my_module_menus', array());
  76. unset($my_menus[$menu['menu_name']]);
  77. variable_set('my_module_menus', $my_menus);
  78. }
  79. /**
  80. * @} End of "addtogroup hooks".
  81. */

Functions

Namesort descending Description
hook_menu_delete Respond to a custom menu deletion.
hook_menu_insert Respond to a custom menu creation.
hook_menu_update Respond to a custom menu update.