array( 'hooks' => array( 'go_to_sleep' => array('run'), ), 'description' => t('Read books to young children'), 'configurable' => FALSE, 'type' => 'dojo', ), ); } /** * The read_book action that is called by dojo_action_info(). * * Reads a book. */ function dojo_read_book_action() { // Anything you want accomplished can go in here. drupal_set_message(t('Reading book')); } /** * Implementation of hook_hook_info(). * * Defines the go_to_sleep trigger (or at least it should). */ function dojo_hook_info() { return array( 'dojo' => array( 'go_to_sleep' => array( 'run' => array( 'runs when' => t('Drupal wants to go to sleep'), ), ), ), ); } function dojo_exit() { module_invoke_all('dojo'); } function trigger_dojo() { // _trigger_get_hook_aids is defined in trigger.module $aids = _trigger_get_hook_aids('dojo', 'run'); $context = array( 'hook' => 'dojo', 'op' => '', ); // Dojo does not act on any specific object. $object = NULL; actions_do(array_keys($aids), $object, $context); } /** * Implementation of hook_footer(). * * Triggers our alias, the hook_go_to_sleep */ function dojo_footer() { // Invoke the hook module_invoke_all('go_to_sleep'); } /** * Implementation of hook_go_to_sleep(). */ function dojo_go_to_sleep() { // Get all actions from this trigger $actions = _trigger_get_hook_aids('go_to_sleep'); // Initialize a dummy object $obj = (object) array(); // Do the actions on the dummy object actions_do($actions, $obj); }