function trigger_example_triggersomething
Trigger: triggersomething. Run actions associated with an arbitrary event.
Here pressing a button is a trigger. We have defined a custom function as a trigger (trigger_example_triggersomething). It will ask for all actions attached to the 'triggersomething' event, prepare a basic 'context' for them and run all of them. This could have been implemented by a hook implementation, but in this demonstration, it will just be called in a form's submit.
This function is executed during the submission of the example form defined in this module.
Parameters
array $options: Array of arguments used to call the triggersomething function, if any.
Related topics
1 call to trigger_example_triggersomething()
- trigger_example_form_submit in trigger_example/
trigger_example.module - Submit handler for the trigger_example_form().
File
-
trigger_example/
trigger_example.module, line 128
Code
function trigger_example_triggersomething($options = array()) {
// Ask the trigger module for all actions enqueued for the 'triggersomething'
// trigger.
$aids = trigger_get_assigned_actions('triggersomething');
// Prepare a basic context, indicating group and "hook", and call all the
// actions with this context as arguments.
$context = array(
'group' => 'trigger_example',
'hook' => 'triggersomething',
);
actions_do(array_keys($aids), (object) $options, $context);
}