Community Documentation

Event Info reference

Last updated December 13, 2007. Created by fago on July 4, 2007.
Edited by Michelle, webchick. Log in to edit this page.

event_info

This is a list of properties available for the elements returned in implementations of hook_event_info.

Property Possible values Default value Description Required
#label * - A human readable label for the event Yes
#module * - The name of the contributing module. Can be set to any value, as it is only used for grouping entries. Yes
#arguments see below array() An array specifying the needed arguments. No
#description * "" A text which will be displayed on the page of a configuration, which is evaluated on this event. This can be used to provide some further notes regarding this event. No
#redirect FALSE | TRUE FALSE Whether usually a page redirect with drupal_goto is issued after the event has occurred. This information is just used by the path redirect action to provide sensible defaults. Read more No
#fixed FALSE | TRUE FALSE If set to TRUE, the action or condition is used only by modules and should not be available for configuration through the UI. No

#arguments

The #arguments property specifies the available arguments. It has to be an array of arguments, where the keys are the machine readable name of the argument and the value is another array, with the properties:

Property Possible values Default value Description Required
#label * - A human readable label for the argument Yes
#entity * - The entity type of the argument, e.g. 'node', 'user' or 'comment', ... Yes
#saved FALSE | TRUE FALSE If the argument is saved after the event has been invoked, workflow-ng doesn't need to save the argument. So set #saved to TRUE for this case, but be sure to pass the argument by reference to workflow-ng. No
#handler * - The function name of the handler to load this argument No

If the argument isn't available when the event is invoked, the function #handler is called to load the argument as soon as it is needed. So you have to either pass the argument to the workflow-ng when you invoke the event, or you have to implement the #handler function.
When you invoke the event, pass the arguments in the same order as specified in #arguments.

E.g. this argument declaration of worklflow-ng:

<?php
...
   
'node_submit' => array(
     
'#label' => t('Content is going to be saved'),
     
'#module' => t('Node'),
     
'#arguments' => array(
       
'node' => array('#entity' => 'node', '#label' => t('content'), '#saved' => TRUE),
       
'author' => array('#entity' => 'user', '#label' => t('content author'), '#handler' => 'workflow_ng_events_argument_node_author'),
       
'node_unchanged' => array('#entity' => 'node', '#label' => t('unchanged content'), '#handler' => 'workflow_ng_events_argument_node_unchanged'),
       
'author_unchanged' => array('#entity' => 'user', '#label' => t('unchanged content\'s author'), '#handler' => 'workflow_ng_events_argument_unchanged_node_author'),
      ),
     
'#redirect' => TRUE,
  ),
...
?>

is invoked that way:
<?php
workflow_ng_invoke_event
('node_submit', array('node' => &$node));
?>

One could also write

<?php
workflow_ng_invoke_event
('node_submit', $node);
?>

but in this case the node won't be passed by reference for php4 users. So the changes done by the executed actions wouldn't apply to the original node object - and so they won't get saved automatically by the node module. So if you set #saved to TRUE, don't forget to pass the argument by reference.

Alter events

It's also possible to alter event definitions of other modules, e.g. to add further dynamic loaded arguments.
To so implement hook_event_info_alter(&$events).

About this page

Drupal version
Drupal 5.x
Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.