You are here

protected function StateMachine::create_state in State Machine 6

Same name and namespace in other branches
  1. 7.3 inc/base.inc \StateMachine::create_state()
  2. 7 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.
2 calls to StateMachine::create_state()
StateFlow::init in modules/state_flow/plugins/state_flow.inc
Initialize the state machine using the provided addState and addEvent methods.
StateMachine_Test::init in tests/state_machine.test
Called from StateMachine::__construct to initialize the states and events.

File

inc/base.inc, line 47

Class

StateMachine

Code

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