function ContentEntityStorageBase::getLatestRevisionId

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

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.