You are here

protected function StateMachine::create_state in State Machine 7

Same name and namespace in other branches
  1. 6 inc/base.inc \StateMachine::create_state()
  2. 7.3 inc/base.inc \StateMachine::create_state()
  3. 7.2 inc/base.inc \StateMachine::create_state()

Create a new state. This method does not actually create a state instance, it only stores the options array until an instance is requested from get_state().

Parameters

$key: The string identifier for this state. Must be unique within the scope of the State Machine.

$options: An array of options that will be passed into the State constructor.

  • title: The human-readable title of the state.
  • on_enter: An array of callbacks to be fired when entering this state.
  • on_exit: An array of callbacks to be fired when exiting this state.
3 calls to StateMachine::create_state()
StateFlow::init in modules/state_flow/plugins/state_flow.inc
Called from StateMachine::__construct to initialize the states and events. Define two states. First revision:
StateMachine_Test::init in tests/state_machine.test
Called from StateMachine::__construct to initialize the states and events.
TestMachine::init in ./state_machine.api.php
Called from StateMachine::__construct to initialize the states and events.

File

inc/base.inc, line 50
base.inc

Class

StateMachine
@file base.inc

Code

protected function create_state($key, $options = array()) {
  $this->states[$key] = $options;
}