You are here

public function ContentEntityBase::wasDefaultRevision in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::wasDefaultRevision()

Checks whether the entity object was a default revision when it was saved.

Return value

bool TRUE if the entity object was a revision, FALSE otherwise.

Overrides RevisionableInterface::wasDefaultRevision

File

core/lib/Drupal/Core/Entity/ContentEntityBase.php, line 348

Class

ContentEntityBase
Implements Entity Field API specific enhancements to the Entity class.

Namespace

Drupal\Core\Entity

Code

public function wasDefaultRevision() {

  /** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
  $entity_type = $this
    ->getEntityType();
  if (!$entity_type
    ->isRevisionable()) {
    return TRUE;
  }
  $revision_default_key = $entity_type
    ->getRevisionMetadataKey('revision_default');
  $value = $this
    ->isNew() || $this
    ->get($revision_default_key)->value;
  return $value;
}