You are here

public function StateMachine::get_available_events in State Machine 6

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

Returns an array of events that are valid for the current state.

File

inc/base.inc, line 195

Class

StateMachine

Code

public function get_available_events() {
  $events = array();
  foreach (array_keys($this->events) as $key) {
    if ($this
      ->get_event($key)
      ->can_transition_from($this
      ->get_current_state())) {
      $events[] = $key;
    }
  }
  return $events;
}