You are here

public function ContentEntityStorageBase::getLatestTranslationAffectedRevisionId in Drupal 10

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

Returns the latest revision affecting the specified translation.

Parameters

int|string $entity_id: The entity identifier.

string $langcode: The language code of the translation.

Return value

int|string|null A revision ID or NULL if no revision affecting the specified translation could be found.

Overrides TranslatableRevisionableStorageInterface::getLatestTranslationAffectedRevisionId

File

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

Class

ContentEntityStorageBase
Base class for content entity storage handlers.

Namespace

Drupal\Core\Entity

Code

public function getLatestTranslationAffectedRevisionId($entity_id, $langcode) {
  if (!$this->entityType
    ->isRevisionable()) {
    return NULL;
  }
  if (!$this->entityType
    ->isTranslatable()) {
    return $this
      ->getLatestRevisionId($entity_id);
  }
  if (!isset($this->latestRevisionIds[$entity_id][$langcode])) {
    $result = $this
      ->getQuery()
      ->allRevisions()
      ->condition($this->entityType
      ->getKey('id'), $entity_id)
      ->condition($this->entityType
      ->getKey('revision_translation_affected'), 1, '=', $langcode)
      ->range(0, 1)
      ->sort($this->entityType
      ->getKey('revision'), 'DESC')
      ->accessCheck(FALSE)
      ->execute();
    $this->latestRevisionIds[$entity_id][$langcode] = key($result);
  }
  return $this->latestRevisionIds[$entity_id][$langcode];
}