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