You are here

public function OpignoActivity::preSaveRevision in Opigno module 8

Same name and namespace in other branches
  1. 3.x src/Entity/OpignoActivity.php \Drupal\opigno_module\Entity\OpignoActivity::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/OpignoActivity.php, line 453

Class

OpignoActivity
Defines the Activity entity.

Namespace

Drupal\opigno_module\Entity

Code

public function preSaveRevision(EntityStorageInterface $storage, \stdClass $record) {
  parent::preSaveRevision($storage, $record);
  $revision_log_field_name = static::getRevisionMetadataKey($this
    ->getEntityType(), 'revision_log_message');
  $revision_created_field_name = static::getRevisionMetadataKey($this
    ->getEntityType(), 'revision_created');
  $new_revision = $this
    ->isNewRevision();
  if (!$new_revision && isset($this->original) && (!isset($record->{$revision_log_field_name}) || $record->{$revision_log_field_name} === '')) {
    $record->{$revision_log_field_name} = $this->original
      ->getRevisionLogMessage();
  }
  if ($new_revision && (!isset($record->{$revision_created_field_name}) || empty($record->{$revision_created_field_name}))) {
    $record->{$revision_created_field_name} = $record->id == $this
      ->id() ? $this
      ->getCreatedTime() : \Drupal::time()
      ->getRequestTime();
  }
}