You are here

public function ContentEntityStorageBase::getLatestRevisionId in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getLatestRevisionId()
  2. 10 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getLatestRevisionId()

Returns the latest revision identifier for an entity.

Parameters

int|string $entity_id: The entity identifier.

Return value

int|string|null The latest revision identifier or NULL if no revision could be found.

Overrides RevisionableStorageInterface::getLatestRevisionId

1 call to ContentEntityStorageBase::getLatestRevisionId()
ContentEntityStorageBase::getLatestTranslationAffectedRevisionId in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Returns the latest revision affecting the specified translation.

File

core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php, line 384

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

public function getLatestRevisionId($entity_id) {
  if (!$this->entityType
    ->isRevisionable()) {
    return NULL;
  }
  if (!isset($this->latestRevisionIds[$entity_id][LanguageInterface::LANGCODE_DEFAULT])) {
    $result = $this
      ->getQuery()
      ->latestRevision()
      ->condition($this->entityType
      ->getKey('id'), $entity_id)
      ->accessCheck(FALSE)
      ->execute();
    $this->latestRevisionIds[$entity_id][LanguageInterface::LANGCODE_DEFAULT] = key($result);
  }
  return $this->latestRevisionIds[$entity_id][LanguageInterface::LANGCODE_DEFAULT];
}