You are here

protected function StateMachine::create_event in State Machine 7.2

Same name and namespace in other branches
  1. 6 inc/base.inc \StateMachine::create_event()
  2. 7.3 inc/base.inc \StateMachine::create_event()
  3. 7 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

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

$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.
4 calls to StateMachine::create_event()
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:
StateFlowTest::init in modules/state_flow/state_flow.api.php
* Override the init method to set the new states * * Add a to review state and "Review" event
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 132
base.inc

Class

StateMachine
@file base.inc

Code

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