You are here

public function ConfigEntityRevisionsConfigEntityTrait::wasDefaultRevision in Config Entity Revisions 8.2

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.

File

src/ConfigEntityRevisionsConfigEntityTrait.php, line 402

Class

ConfigEntityRevisionsConfigEntityTrait
Trait ConfigEntityRevisionsConfigEntityTrait.

Namespace

Drupal\config_entity_revisions

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;
}