function ContentTranslationPendingRevisionTestBase::loadRevisionTranslation

Same name in other branches
  1. 8.9.x 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()
  3. 11.x 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 135

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

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