function _trigger_node

7.x trigger.module _trigger_node($node, $hook, $a3 = NULL, $a4 = NULL)

Calls action functions for node triggers.

Parameters

$node: Node object.

$hook: Hook to trigger.

$a3: Additional argument to action function.

$a4: Additional argument to action function.

5 calls to _trigger_node()
trigger_node_delete in drupal-7.x/modules/trigger/trigger.module
Implements hook_node_delete().
trigger_node_insert in drupal-7.x/modules/trigger/trigger.module
Implements hook_node_insert().
trigger_node_presave in drupal-7.x/modules/trigger/trigger.module
Implements hook_node_presave().
trigger_node_update in drupal-7.x/modules/trigger/trigger.module
Implements hook_node_update().
trigger_node_view in drupal-7.x/modules/trigger/trigger.module
Implements hook_node_view().

File

drupal-7.x/modules/trigger/trigger.module, line 267
Enables functions to be stored and executed at a later time.

Code

function _trigger_node($node, $hook, $a3 = NULL, $a4 = NULL) {
  // Keep objects for reuse so that changes actions make to objects can persist.
  static $objects;
  // Prevent recursion by tracking which operations have already been called.
  static $recursion;

  $aids = trigger_get_assigned_actions($hook);
  if (!$aids) {
    return;
  }

  if (isset($recursion[$hook])) {
    return;
  }
  $recursion[$hook] = TRUE;

  $context = array(
    'group' => 'node',
    'hook' => $hook,
  );

  // We need to get the expected object if the action's type is not 'node'.
  // 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 != 'node') {
      if (!isset($objects[$type])) {
        $objects[$type] = _trigger_normalize_node_context($type, $node);
      }
      // Since we know about the node, we pass that info along to the action.
      $context['node'] = $node;
      $result = actions_do($aid, $objects[$type], $context, $a3, $a4);
    }
    else {
      actions_do($aid, $node, $context, $a3, $a4);
    }
  }

  unset($recursion[$hook]);
}