function ContentEntityStorageBase::getLatestRevisionId

Same name in other branches
  1. 8.9.x 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()
  3. 11.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getLatestRevisionId()

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 478

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

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