You are here

protected function StateMachine::create_state in State Machine 7.3

Same name and namespace in other branches
  1. 6 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

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

array $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()
StateFlowEntity::init in modules/state_flow_entity/plugins/state_flow_entity.inc
Called from StateMachine::__construct to initialize the states and events.
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 63
Defines the base classes of the state machine.

Class

StateMachine
The base class.

Code

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