public function StateFlowEntity::set_available_publish_revision in State Machine 7.3
Set the vid from the node table as the "Published" revision.
If the node is not currently published then there is no Published revision. It only needs to set this id when the entity first loads. Keep that test to see if it's already set or it gets confused when creating new revisions.
3 calls to StateFlowEntity::set_available_publish_revision()
- StateFlowEntity::init in modules/
state_flow_entity/ plugins/ state_flow_entity.inc - Called from StateMachine::__construct to initialize the states and events.
- StateFlowEntity::isActivePublishedRevision in modules/
state_flow_entity/ plugins/ state_flow_entity.inc - Check if the current object is the active published revision.
- StateFlowEntity::isDraftRevision in modules/
state_flow_entity/ plugins/ state_flow_entity.inc - Check if the current object is a draft revision.
File
- modules/
state_flow_entity/ plugins/ state_flow_entity.inc, line 81 - State Flow implementation of the State Machine class.
Class
- StateFlowEntity
- @file State Flow implementation of the State Machine class.
Code
public function set_available_publish_revision() {
if (!isset($this->object->published_revision_id) && !empty($this->object->{$this
->get_revision_key()})) {
$this->object->published_revision_id = 0;
$entity_type = $this
->get_entity_type();
$entity_info = entity_get_info($entity_type);
if (isset($entity_info['base table'])) {
$published_revision = db_select($entity_info['base table'])
->fields('node', array(
$this
->get_revision_key(),
))
->condition('nid', $this->object->{$this
->get_entity_id_key()})
->condition('status', 1)
->execute()
->fetchCol();
if (!empty($published_revision)) {
$this->object->published_revision_id = $published_revision[0];
}
}
}
}