You are here

public function OpignoCertificate::preSaveRevision in Opigno certificate 8

Same name and namespace in other branches
  1. 3.x src/Entity/OpignoCertificate.php \Drupal\opigno_certificate\Entity\OpignoCertificate::preSaveRevision()

Acts on a revision before it gets saved.

Parameters

EntityStorageInterface $storage: The entity storage object.

object $record: The revision object.

Overrides ContentEntityBase::preSaveRevision

File

src/Entity/OpignoCertificate.php, line 98

Class

OpignoCertificate
Defines the opigno_certificate entity class.

Namespace

Drupal\opigno_certificate\Entity

Code

public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
  parent::preSaveRevision($storage, $record);
  if (!$this
    ->isNewRevision() && isset($this->original) && (!isset($record->revision_log) || $record->revision_log === '')) {

    // If we are updating an existing opigno_certificate
    // without adding a new revision, we need
    // to make sure $entity->revision_log is reset whenever it is empty.
    // Therefore, this code allows us to avoid clobbering an existing log
    // entry with an empty one.
    $record->revision_log = $this->original->revision_log->value;
  }
}