Project

General

Profile

Paste
Download (2.62 KB) Statistics
| Branch: | Revision:

root / drupal7 / modules / trigger / trigger.api.php @ 27e02aed

1
<?php
2

    
3
/**
4
 * @file
5
 * Hooks provided by the Trigger module.
6
 */
7

    
8
/**
9
 * @addtogroup hooks
10
 * @{
11
 */
12

    
13
/**
14
 * Declare triggers (events) for users to assign actions to.
15
 *
16
 * This hook is used by the trigger module to create a list of triggers (events)
17
 * that users can assign actions to. Your module is responsible for detecting
18
 * that the events have occurred, calling trigger_get_assigned_actions() to find
19
 * out which actions the user has associated with your trigger, and then calling
20
 * actions_do() to fire off the actions.
21
 *
22
 * @return
23
 *   A nested associative array.
24
 *   - The outermost key is the name of the module that is defining the triggers.
25
 *     This will be used to create a local task (tab) in the trigger module's
26
 *     user interface. A contrib module may supply a trigger for a core module by
27
 *     giving the core module's name as the key. For example, you could use the
28
 *     'node' key to add a node-related trigger.
29
 *     - Within each module, each individual trigger is keyed by a hook name
30
 *       describing the particular trigger (this is not visible to the user, but
31
 *       can be used by your module for identification).
32
 *       - Each trigger is described by an associative array. Currently, the only
33
 *         key-value pair is 'label', which contains a translated human-readable
34
 *         description of the triggering event.
35
 *   For example, the trigger set for the 'node' module has 'node' as the
36
 *   outermost key and defines triggers for 'node_insert', 'node_update',
37
 *   'node_delete' etc. that fire when a node is saved, updated, etc.
38
 *
39
 * @see hook_action_info()
40
 * @see hook_trigger_info_alter()
41
 */
42
function hook_trigger_info() {
43
  return array(
44
    'node' => array(
45
      'node_presave' => array(
46
        'label' => t('When either saving new content or updating existing content'),
47
      ),
48
      'node_insert' => array(
49
        'label' => t('After saving new content'),
50
      ),
51
      'node_update' => array(
52
        'label' => t('After saving updated content'),
53
      ),
54
      'node_delete' => array(
55
        'label' => t('After deleting content'),
56
      ),
57
      'node_view' => array(
58
        'label' => t('When content is viewed by an authenticated user'),
59
      ),
60
    ),
61
  );
62
}
63

    
64
/**
65
 * Alter triggers declared by hook_trigger_info().
66
 *
67
 * @param $triggers
68
 *   Array of trigger information returned by hook_trigger_info()
69
 *   implementations. Modify this array in place. See hook_trigger_info()
70
 *   for information on what this might contain.
71
 */
72
function hook_trigger_info_alter(&$triggers) {
73
  $triggers['node']['node_insert']['label'] = t('When content is saved');
74
}
75

    
76
/**
77
 * @} End of "addtogroup hooks".
78
 */