You are here

public function StateFlow::init in State Machine 6

Same name and namespace in other branches
  1. 7 modules/state_flow/plugins/state_flow.inc \StateFlow::init()
  2. 7.2 modules/state_flow/plugins/state_flow.inc \StateFlow::init()

Initialize the state machine using the provided addState and addEvent methods.

Overrides StateMachine::init

File

modules/state_flow/plugins/state_flow.inc, line 10

Class

StateFlow

Code

public function init() {

  // Initialize states
  $this
    ->create_state('draft');
  $this
    ->create_state('published', array(
    'on_enter' => array(
      $this,
      'on_enter_published',
    ),
    'on_exit' => array(
      $this,
      'on_exit_published',
    ),
  ));

  // Initialize events
  $this
    ->create_event('publish', array(
    'origin' => 'draft',
    'target' => 'published',
  ));
  $this
    ->create_event('unpublish', array(
    'origin' => 'published',
    'target' => 'draft',
  ));
}