You are here

public function BlockContent::preSaveRevision in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/block_content/src/Entity/BlockContent.php \Drupal\block_content\Entity\BlockContent::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

core/modules/block_content/src/Entity/BlockContent.php, line 154

Class

BlockContent
Defines the custom block entity class.

Namespace

Drupal\block_content\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 block_content without adding a new
    // revision and the user did not supply a revision log, keep the existing
    // one.
    $record->revision_log = $this->original
      ->getRevisionLogMessage();
  }
}