public function StateFlowEntity::set_current_history in State Machine 7.3
Provide history with each revision.
@todo, this does not need to be in state_flow_node.inc. It could easily get abstracted to state_flow_entity.inc
1 call to StateFlowEntity::set_current_history()
- StateFlowEntity::init in modules/
state_flow_entity/ plugins/ state_flow_entity.inc - Called from StateMachine::__construct to initialize the states and events.
File
- modules/
state_flow_entity/ plugins/ state_flow_entity.inc, line 105 - State Flow implementation of the State Machine class.
Class
- StateFlowEntity
- @file State Flow implementation of the State Machine class.
Code
public function set_current_history() {
// Set defaults.
$this->object->current_state = '';
$this->object->current_log = '';
$this->object->current_state_timestamp = '';
$result = db_select('state_flow_history', 'sfh')
->fields('sfh', array(
'state',
'timestamp',
'log',
))
->condition('entity_id', $this->object->{$this
->get_entity_id_key()})
->condition('revision_id', $this->object->{$this
->get_revision_key()})
->orderBy('timestamp', 'DESC')
->range(0, 1)
->execute()
->fetchObject();
// Set actual data if found any.
if ($result) {
$this->object->current_state = $result->state;
$this->object->current_log = $result->log;
$this->object->current_state_timestamp = $result->timestamp;
}
}