You are here

public function StateFlow::persist in State Machine 6

Same name and namespace in other branches
  1. 7 modules/state_flow/plugins/state_flow.inc \StateFlow::persist()
  2. 7.2 modules/state_flow/plugins/state_flow.inc \StateFlow::persist()

Persist the current state to the object storage.

Overrides StateMachine::persist

File

modules/state_flow/plugins/state_flow.inc, line 46

Class

StateFlow

Code

public function persist() {
  $vid = $this
    ->get_latest_revision($this->object->nid);
  $nid = $this->object->nid;
  $state = $this
    ->get_current_state();
  $data = array(
    'vid' => $vid,
    'nid' => $nid,
    'state' => $state,
    'timestamp' => time(),
    'status' => 1,
  );
  $update = $this
    ->existing_revision($nid, $vid) ? array(
    'vid',
  ) : NULL;
  $result = drupal_write_record('node_revision_states', $data, $update);
  return;
}