Commit 1b6127b0 authored by webchick's avatar webchick

Issue #2108679 by ianthomas_uk, sun: API documentation: Convert...

Issue #2108679 by ianthomas_uk, sun: API documentation: Convert my_module_menus examples in menu.api.php to CMI.
parent fdca37f8
...@@ -17,17 +17,16 @@ ...@@ -17,17 +17,16 @@
* Contributed modules may use the information to perform actions based on the * Contributed modules may use the information to perform actions based on the
* information entered into the menu system. * information entered into the menu system.
* *
* @param \Drupal\system\Entity\Menu $menu * @param \Drupal\system\MenuInterface $menu
* A menu entity. * The menu entity that was created.
* *
* @see hook_menu_update() * @see hook_menu_update()
* @see hook_menu_delete() * @see hook_menu_delete()
*/ */
function hook_menu_insert($menu) { function hook_menu_insert(\Drupal\system\MenuInterface $menu) {
// For example, we track available menus in a variable. drupal_set_message(t('You have just created a menu with a machine name %id.', array(
$my_menus = variable_get('my_module_menus', array()); '%id' => $menu->id(),
$my_menus[$menu->id()] = $menu->id(); )));
variable_set('my_module_menus', $my_menus);
} }
/** /**
...@@ -37,17 +36,19 @@ function hook_menu_insert($menu) { ...@@ -37,17 +36,19 @@ function hook_menu_insert($menu) {
* Contributed modules may use the information to perform actions based on the * Contributed modules may use the information to perform actions based on the
* information entered into the menu system. * information entered into the menu system.
* *
* @param \Drupal\system\Entity\Menu $menu * @param \Drupal\system\MenuInterface $menu
* A menu entity. * The menu entity that was updated.
* *
* @see hook_menu_insert() * @see hook_menu_insert()
* @see hook_menu_delete() * @see hook_menu_delete()
*/ */
function hook_menu_update($menu) { function hook_menu_update(\Drupal\system\MenuInterface $menu) {
// For example, we track available menus in a variable. if ($type->original->id() != $type->id()) {
$my_menus = variable_get('my_module_menus', array()); drupal_set_message(t('You have just changed the machine name of the menu %old_id to %id.', array(
$my_menus[$menu->id()] = $menu->id(); '%old_id' => $menu->original->id(),
variable_set('my_module_menus', $my_menus); '%id' => $menu->id(),
)));
}
} }
/** /**
...@@ -58,17 +59,16 @@ function hook_menu_update($menu) { ...@@ -58,17 +59,16 @@ function hook_menu_update($menu) {
* information to perform actions based on the information entered into the menu * information to perform actions based on the information entered into the menu
* system. * system.
* *
* @param \Drupal\system\Entity\Menu $menu * @param \Drupal\system\MenuInterface $menu
* A menu entity. * The menu entity that was deleted.
* *
* @see hook_menu_insert() * @see hook_menu_insert()
* @see hook_menu_update() * @see hook_menu_update()
*/ */
function hook_menu_delete($menu) { function hook_menu_delete(\Drupal\system\MenuInterface $menu) {
// Delete the record from our variable. drupal_set_message(t('You have just deleted the menu with machine name %id.', array(
$my_menus = variable_get('my_module_menus', array()); '%id' => $menu->id(),
unset($my_menus[$menu->id()]); )));
variable_set('my_module_menus', $my_menus);
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment