public function StateFlow::fire_event in State Machine 7.2
Same name and namespace in other branches
- 7 modules/state_flow/plugins/state_flow.inc \StateFlow::fire_event()
Extending fire_event() from state_machine's base.inc to add uid and log arguments.
Overrides StateMachine::fire_event
File
- modules/
state_flow/ plugins/ state_flow.inc, line 155
Class
Code
public function fire_event($key, $uid = NULL, $log = '') {
$event = $this
->get_event($key);
if ($event && ($new_state = $event
->execute())) {
// Allow the previous state to run its 'on_exit' callbacks.
$this
->get_state($this
->get_current_state())
->on_exit();
// Set and save the new state.
$this
->set_current_state($new_state);
$this
->persist();
// Write a history record for this state change.
if (empty($uid)) {
global $user;
$uid = $user->uid;
}
$this
->write_history($uid, $log);
// Allow the new state to run its 'on_enter' callbacks.
$this
->get_state($this
->get_current_state())
->on_enter();
// Allow the event to "finish".
$event
->finish();
// Allow state_flow to provide other hooks or event triggers.
state_flow_invoke_event_handlers($this, $key, $uid, $log);
}
else {
$this
->on_event_fail($event);
return FALSE;
}
}