menu.api.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Menu module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Informs modules that a custom menu was created.
  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. * Informs modules that a custom menu was updated.
  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. * Informs modules that a custom menu was deleted.
  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 $link
  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. */