You are here

function state_flow_invoke_event_handlers in State Machine 7.2

Same name and namespace in other branches
  1. 7 modules/state_flow/state_flow.module \state_flow_invoke_event_handlers()

Inform external systems about a workflow transition.

1 call to state_flow_invoke_event_handlers()
StateFlow::fire_event in modules/state_flow/plugins/state_flow.inc
Extending fire_event() from state_machine's base.inc to add uid and log arguments.

File

modules/state_flow/state_flow.module, line 314
An implementation of node revision workflow for Drupal based on the State Machine system.

Code

function state_flow_invoke_event_handlers(StateMachine $state_machine, $event_key, $uid, $log) {

  // Load related objects
  $object = $state_machine
    ->get_object();
  if (is_object($object)) {
    $state = $state_machine
      ->get_current_state();
    $node = node_load($object->nid, $object->vid);
    $author = !empty($node->uid) ? user_load($node->uid) : drupal_anonymous_user();

    // Invoke the Rules state_flow_event_fired event.
    if ($node && module_exists('rules')) {
      rules_invoke_event('state_flow_event_fired', $node, $author, $state);
    }

    // Make sure Apachesolr gets update
    if ($node && module_exists('apachesolr')) {
      module_invoke('apachesolr', 'entity_update', $node, 'node');
    }
    module_invoke_all('state_flow_event_fired', $node, $event_key, $uid, $log);
  }
}