menu_node_test.module in Menu Node API 7
Test module for Menu Node API hooks.
File
tests/menu_node_test.moduleView source
<?php
/**
* @file
* Test module for Menu Node API hooks.
*/
/**
* Store static variables to indicate that hooks fired.
*/
function menu_node_test_set($value = NULL) {
static $storage;
if (is_null($value) && isset($storage)) {
return $storage;
}
$storage = $value;
}
/**
* Get the static value.
*/
function menu_node_test_get() {
return menu_node_test_set();
}
/**
* Implements hook_menu_node_invoke_insert().
*/
function menu_node_test_menu_node_invoke_insert($link, $node) {
// On insert, increment the count and set a static indicator, so we
// can count how many times this operation has run.
$i =& drupal_static(__FUNCTION__);
if (!empty($link->mlid) && !empty($node->nid)) {
menu_node_test_set('insert' . $i++);
}
}
/**
* Implements hook_menu_node_invoke_update().
*/
function menu_node_test_menu_node_invoke_update($link, $node) {
$i =& drupal_static(__FUNCTION__);
if (!empty($link->mlid) && !empty($node->nid)) {
menu_node_test_set('update' . $i++);
}
}
/**
* Implements hook_menu_node_invoke_delete().
*/
function menu_node_test_menu_node_invoke_delete($link, $node) {
$i =& drupal_static(__FUNCTION__);
if (!empty($link->mlid) && !empty($node->nid)) {
menu_node_test_set('delete' . $i++);
}
}
Functions
Name | Description |
---|---|
menu_node_test_get | Get the static value. |
menu_node_test_menu_node_invoke_delete | Implements hook_menu_node_invoke_delete(). |
menu_node_test_menu_node_invoke_insert | Implements hook_menu_node_invoke_insert(). |
menu_node_test_menu_node_invoke_update | Implements hook_menu_node_invoke_update(). |
menu_node_test_set | Store static variables to indicate that hooks fired. |