You are here

class StateMachine_State in State Machine 7.2

Same name and namespace in other branches
  1. 6 inc/base.inc \StateMachine_State
  2. 7.3 inc/base.inc \StateMachine_State
  3. 7 inc/base.inc \StateMachine_State

Hierarchy

Expanded class hierarchy of StateMachine_State

File

inc/base.inc, line 224
base.inc

View source
class StateMachine_State {
  public $key;
  protected $machine;
  protected $options;
  public function __construct($key, $machine, $options = array()) {
    $this->key = $key;
    $this->machine = $machine;
    $this->options = $options;
  }

  /**
   * Return the $options array
   */
  public function get_options() {
    return $this->options;
  }

  /**
   * Return a specific key value from the $options array
   */
  public function get_option($key) {
    return array_key_exists($key, $this->options) ? $this->options[$key] : FALSE;
  }

  /**
   * Called when entering into this state.
   */
  public function on_enter() {
    $args = func_get_args();
    if (!empty($this->options['on_enter'])) {
      call_user_func_array($this->options['on_enter'], $args);
    }
  }

  /**
   * Called when exiting out of this state.
   */
  public function on_exit() {
    $args = func_get_args();
    if (!empty($this->options['on_exit'])) {
      call_user_func_array($this->options['on_exit'], $args);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StateMachine_State::$key public property
StateMachine_State::$machine protected property
StateMachine_State::$options protected property
StateMachine_State::get_option public function Return a specific key value from the $options array
StateMachine_State::get_options public function Return the $options array
StateMachine_State::on_enter public function Called when entering into this state.
StateMachine_State::on_exit public function Called when exiting out of this state.
StateMachine_State::__construct public function