diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index 96ebb4c..1931ad6 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -186,6 +186,30 @@ public function getLatestRevisionId($entity_id) { /** * {@inheritdoc} */ + public function getLatestAffectedRevisionId($entity_id, $langcode) { + if (!$this->entityType->isRevisionable()) { + return NULL; + } + + if (!$this->entityType->isTranslatable()) { + return $this->getLatestRevisionId($entity_id); + } + + $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(); + + return key($result); + } + + /** + * {@inheritdoc} + */ public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition) {} /** diff --git a/core/lib/Drupal/Core/Entity/RevisionableStorageInterface.php b/core/lib/Drupal/Core/Entity/RevisionableStorageInterface.php index 3a1dbac..6729c68 100644 --- a/core/lib/Drupal/Core/Entity/RevisionableStorageInterface.php +++ b/core/lib/Drupal/Core/Entity/RevisionableStorageInterface.php @@ -39,4 +39,17 @@ public function deleteRevision($revision_id); */ public function getLatestRevisionId($entity_id); + /** + * Returns the latest affected revision identifier for an entity translation. + * + * @param int $entity_id + * The entity identifier. + * @param string $langcode + * The language code of the translation. + * + * @return int|null + * The latest revision identifier or NULL if no revision could be found. + */ + public function getLatestAffectedRevisionId($entity_id, $langcode); + } diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php index 2a2e4a6..698ed85 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php @@ -30,4 +30,11 @@ public function getLatestRevisionId($entity_id) { return NULL; } + /** + * {@inheritdoc} + */ + public function getLatestAffectedRevisionId($entity_id, $langcode) { + return NULL; + } + }