You are here

public function ContentEntityBase::isDefaultRevision in Drupal 9

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

Checks if this entity is the default revision.

Parameters

bool $new_value: (optional) A Boolean to (re)set the isDefaultRevision flag.

Return value

bool TRUE if the entity is the default revision, FALSE otherwise. If $new_value was passed, the previous value is returned.

Overrides RevisionableInterface::isDefaultRevision

2 calls to ContentEntityBase::isDefaultRevision()
MenuLinkContent::postSave in core/modules/menu_link_content/src/Entity/MenuLinkContent.php
Acts on a saved entity before the insert or update hook is invoked.
Node::postSave in core/modules/node/src/Entity/Node.php
Acts on a saved entity before the insert or update hook is invoked.

File

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

Class

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

Namespace

Drupal\Core\Entity

Code

public function isDefaultRevision($new_value = NULL) {
  $return = $this->isDefaultRevision;
  if (isset($new_value)) {
    $this->isDefaultRevision = (bool) $new_value;
  }

  // New entities should always ensure at least one default revision exists,
  // creating an entity without a default revision is an invalid state.
  return $this
    ->isNew() || $return;
}