function ContentEntityBase::wasDefaultRevision

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::wasDefaultRevision()
  2. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::wasDefaultRevision()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::wasDefaultRevision()

File

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

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.