You are here

public function StateMachine_Event::validate in State Machine 7.2

Same name and namespace in other branches
  1. 6 inc/base.inc \StateMachine_Event::validate()
  2. 7.3 inc/base.inc \StateMachine_Event::validate()
  3. 7 inc/base.inc \StateMachine_Event::validate()

Validate that the given event can take place.

2 calls to StateMachine_Event::validate()
StateFlow_Event::validate in modules/state_flow/plugins/state_flow.inc
Validate that the given event can take place.
StateMachine_Event::execute in inc/base.inc
Execute the event.
1 method overrides StateMachine_Event::validate()
StateFlow_Event::validate in modules/state_flow/plugins/state_flow.inc
Validate that the given event can take place.

File

inc/base.inc, line 302
base.inc

Class

StateMachine_Event

Code

public function validate() {

  // Check that the current state is a valid origin for the given transition.
  if (!in_array($this->machine
    ->get_current_state(), $this->options['origin'])) {
    return FALSE;
  }

  // Execute guard condition if it exists.
  if (!empty($this->options['guard'])) {
    if (call_user_func($this->options['guard'], $this) === FALSE) {
      return FALSE;
    }
  }
  return TRUE;
}