public function StateFlowEntity::init in State Machine 7.3
Called from StateMachine::__construct to initialize the states and events.
Define two states. First revision:
- Expose go to draft button
- Expose go to publish button
- Upon publish, create new revision (handled outside of state machine)
Second revision:
- Menu alter edit link to load most recent revision (whether published or revision from states).
- On hook_nodeapi (op: load), force new revision checkbox on node edit
form.
- Expose go to draft button
 
- Create new revision, prevent node table from updating new revision as published revision.
- Expose go to publish button
- Upon publish, set revision id in node table
- Repeat as needed
Overrides StateMachine::init
1 call to StateFlowEntity::init()
- StateFlowEntity::__construct in modules/state_flow_entity/ plugins/ state_flow_entity.inc 
- Create instance of StateMachine.
File
- modules/state_flow_entity/ plugins/ state_flow_entity.inc, line 45 
- State Flow implementation of the State Machine class.
Class
- StateFlowEntity
- @file State Flow implementation of the State Machine class.
Code
public function init($workflow = array()) {
  // Initialize states.
  foreach ($workflow['states'] as $name => $options) {
    // Some methods require $this when called by State Machine e.g. on_exit().
    foreach ($options as $key => $value) {
      if ($key == 'on_exit' || $key == 'on_enter') {
        $options[$key] = array(
          $this,
          $value,
        );
      }
    }
    $this
      ->create_state($name, $options);
  }
  // Initialize events.
  foreach ($workflow['events'] as $name => $options) {
    $this
      ->create_event($name, $options);
  }
  $this->default_state = isset($workflow['default_state']) ? $workflow['default_state'] : NULL;
  // Find publishable vid.
  $this
    ->set_available_publish_revision();
  // Set latest history.
  if (!empty($this->object) && isset($this->object->vid)) {
    $this
      ->set_current_history();
  }
}