You are here

public function StateFlowEntity::latest_state in State Machine 7.3

1 call to StateFlowEntity::latest_state()
StateFlowEntity::load in modules/state_flow_entity/plugins/state_flow_entity.inc
Provide the current state of this revision or entity.

File

modules/state_flow_entity/plugins/state_flow_entity.inc, line 950
State Flow implementation of the State Machine class.

Class

StateFlowEntity
@file State Flow implementation of the State Machine class.

Code

public function latest_state($entity_id) {
  $latest_state = db_select('state_flow_history', 'sfh')
    ->fields('sfh', array(
    'state',
  ))
    ->condition('entity_id', $entity_id)
    ->orderBy('hid', 'DESC')
    ->range(0, 1)
    ->execute()
    ->fetchCol('state');
  return !empty($latest_state[0]) ? $latest_state[0] : FALSE;
}