protected function ContentTranslationPendingRevisionTestBase::loadRevisionTranslation in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_translation/tests/src/Functional/ContentTranslationPendingRevisionTestBase.php \Drupal\Tests\content_translation\Functional\ContentTranslationPendingRevisionTestBase::loadRevisionTranslation()
- 9 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.
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\FunctionalCode
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;
}