You are here

protected function StateMachine::create_event in State Machine 7.3

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

Create a new event.

This method does not actually create an event instance, it only stores the options array until an instance is requested from get_event().

Parameters

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

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

  • title: The human-readable title of the event.
  • origin: A key or array of keys representing the valid origin state(s) for this event.
  • target: The key of the state which this event will transition to.
  • guard: A callback to be fired before the event. If this function returns FALSE, the event will be cancelled.
  • before_transition: A callback to be fired after the guard condition, but before the transition.
  • after_transition: A callback to be fired after the completion of the transition.
3 calls to StateMachine::create_event()
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 151
Defines the base classes of the state machine.

Class

StateMachine
The base class.

Code

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