function ContentEntityStorageBase::getLatestTranslationAffectedRevisionId

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getLatestTranslationAffectedRevisionId()
  2. 8.9.x core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getLatestTranslationAffectedRevisionId()
  3. 10 core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php \Drupal\Core\Entity\ContentEntityStorageBase::getLatestTranslationAffectedRevisionId()

Overrides TranslatableRevisionableStorageInterface::getLatestTranslationAffectedRevisionId

File

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

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

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