function _trigger_comment in Drupal 7
Calls action functions for comment triggers.
Parameters
$a1: Comment object or array of form values.
$hook: Hook to trigger.
5 calls to _trigger_comment()
- trigger_comment_delete in modules/
trigger/ trigger.module - Implements hook_comment_delete().
- trigger_comment_insert in modules/
trigger/ trigger.module - Implements hook_comment_insert().
- trigger_comment_presave in modules/
trigger/ trigger.module - Implements hook_comment_presave().
- trigger_comment_update in modules/
trigger/ trigger.module - Implements hook_comment_update().
- trigger_comment_view in modules/
trigger/ trigger.module - Implements hook_comment_view().
File
- modules/
trigger/ trigger.module, line 416 - Enables functions to be stored and executed at a later time.
Code
function _trigger_comment($a1, $hook) {
// Keep objects for reuse so that changes actions make to objects can persist.
static $objects;
$aids = trigger_get_assigned_actions($hook);
$context = array(
'group' => 'comment',
'hook' => $hook,
);
// We need to get the expected object if the action's type is not 'comment'.
// We keep the object in $objects so we can reuse it if we have multiple
// actions that make changes to an object.
foreach ($aids as $aid => $info) {
$type = $info['type'];
if ($type != 'comment') {
if (!isset($objects[$type])) {
$objects[$type] = _trigger_normalize_comment_context($type, $a1);
}
// Since we know about the comment, we pass it along to the action
// in case it wants to peek at it.
$context['comment'] = (object) $a1;
actions_do($aid, $objects[$type], $context);
}
else {
actions_do($aid, $a1, $context);
}
}
}