function _trigger_comment

You are here

7 trigger.module _trigger_comment($a1, $hook)

Calls action functions for comment triggers.

Parameters

$a1: Comment object or array of form values.

$hook: Hook to trigger.

5 calls to _trigger_comment()

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);
    }
  }
}