trigger.api.php

You are here

Hooks provided by the Trigger module.

Functions

Namesort descending Description
hook_trigger_info Declare triggers (events) for users to assign actions to.
hook_trigger_info_alter Alter triggers declared by hook_trigger_info().

File

modules/trigger/trigger.api.php
View source
  1. <?php
  2. /**
  3. * @file
  4. * Hooks provided by the Trigger module.
  5. */
  6. /**
  7. * @addtogroup hooks
  8. * @{
  9. */
  10. /**
  11. * Declare triggers (events) for users to assign actions to.
  12. *
  13. * This hook is used by the trigger module to create a list of triggers (events)
  14. * that users can assign actions to. Your module is responsible for detecting
  15. * that the events have occurred, calling trigger_get_assigned_actions() to find
  16. * out which actions the user has associated with your trigger, and then calling
  17. * actions_do() to fire off the actions.
  18. *
  19. * @return
  20. * A nested associative array.
  21. * - The outermost key is the name of the module that is defining the triggers.
  22. * This will be used to create a local task (tab) in the trigger module's
  23. * user interface. A contrib module may supply a trigger for a core module by
  24. * giving the core module's name as the key. For example, you could use the
  25. * 'node' key to add a node-related trigger.
  26. * - Within each module, each individual trigger is keyed by a hook name
  27. * describing the particular trigger (this is not visible to the user, but
  28. * can be used by your module for identification).
  29. * - Each trigger is described by an associative array. Currently, the only
  30. * key-value pair is 'label', which contains a translated human-readable
  31. * description of the triggering event.
  32. * For example, the trigger set for the 'node' module has 'node' as the
  33. * outermost key and defines triggers for 'node_insert', 'node_update',
  34. * 'node_delete' etc. that fire when a node is saved, updated, etc.
  35. *
  36. * @see hook_action_info()
  37. * @see hook_trigger_info_alter()
  38. */
  39. function hook_trigger_info() {
  40. return array(
  41. 'node' => array(
  42. 'node_presave' => array(
  43. 'label' => t('When either saving new content or updating existing content'),
  44. ),
  45. 'node_insert' => array(
  46. 'label' => t('After saving new content'),
  47. ),
  48. 'node_update' => array(
  49. 'label' => t('After saving updated content'),
  50. ),
  51. 'node_delete' => array(
  52. 'label' => t('After deleting content'),
  53. ),
  54. 'node_view' => array(
  55. 'label' => t('When content is viewed by an authenticated user'),
  56. ),
  57. ),
  58. );
  59. }
  60. /**
  61. * Alter triggers declared by hook_trigger_info().
  62. *
  63. * @param $triggers
  64. * Array of trigger information returned by hook_trigger_info()
  65. * implementations. Modify this array in place. See hook_trigger_info()
  66. * for information on what this might contain.
  67. */
  68. function hook_trigger_info_alter(&$triggers) {
  69. $triggers['node']['node_insert']['label'] = t('When content is saved');
  70. }
  71. /**
  72. * @} End of "addtogroup hooks".
  73. */