You are here

protected function ContentTranslationPendingRevisionTestBase::loadRevisionTranslation in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationPendingRevisionTestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationPendingRevisionTestBase::loadRevisionTranslation()
  2. 10 core/modules/content_translation/tests/src/Functional/ContentTranslationPendingRevisionTestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationPendingRevisionTestBase::loadRevisionTranslation()

Loads the active revision translation for the specified entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity being edited.

string $langcode: The translation language code.

Return value

\Drupal\Core\Entity\ContentEntityInterface|null The active revision translation or NULL if none could be identified.

1 call to ContentTranslationPendingRevisionTestBase::loadRevisionTranslation()
ContentTranslationRevisionTranslationDeletionTest::doTestOverview in core/modules/content_translation/tests/src/Functional/ContentTranslationRevisionTranslationDeletionTest.php
Performs a test run.

File

core/modules/content_translation/tests/src/Functional/ContentTranslationPendingRevisionTestBase.php, line 134

Class

ContentTranslationPendingRevisionTestBase
Base class for pending revision translation tests.

Namespace

Drupal\Tests\content_translation\Functional

Code

protected function loadRevisionTranslation(ContentEntityInterface $entity, $langcode) {

  // Explicitly invalidate the cache for that node, as the call below is
  // statically cached.
  $this->storage
    ->resetCache([
    $entity
      ->id(),
  ]);
  $revision_id = $this->storage
    ->getLatestTranslationAffectedRevisionId($entity
    ->id(), $langcode);

  /** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
  $revision = $revision_id ? $this->storage
    ->loadRevision($revision_id) : NULL;
  return $revision && $revision
    ->hasTranslation($langcode) ? $revision
    ->getTranslation($langcode) : NULL;
}