1 node.entity.inc protected NodeStorageController::saveRevision(EntityInterface $entity)

Saves a node revision.

Parameters

Node $entity: The node entity whose revision should be saved.

File

core/modules/node/node.entity.inc, line 522
Entity controller and class for nodes.

Class

NodeStorageController
Controller class for nodes.

Code

protected function saveRevision(EntityInterface $entity) {
  $record = clone $entity;
  $record->uid = $entity->revision_uid;
  $record->timestamp = $entity->revision_timestamp;

  if (empty($entity->{$this->revisionKey}) || !empty($entity->revision)) {
    backdrop_write_record($this->revisionTable, $record);
    // Only update the base node table if this revision is the active
    // revision.
    if ($entity->isActiveRevision()) {
      db_update($this->entityInfo['base table'])
        ->fields(array($this->revisionKey => $record->{$this->revisionKey}))
        ->condition($this->idKey, $entity->{$this->idKey})
        ->execute();
    }
  }
  else {
    backdrop_write_record($this->revisionTable, $record, $this->revisionKey);
  }
  // Make sure to update the new revision key for the entity.
  $entity->{$this->revisionKey} = $record->{$this->revisionKey};
}