function ModerationLocaleTest::loadTranslation
Same name in other branches
- 9 core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::loadTranslation()
- 8.9.x core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::loadTranslation()
- 11.x core/modules/content_moderation/tests/src/Functional/ModerationLocaleTest.php \Drupal\Tests\content_moderation\Functional\ModerationLocaleTest::loadTranslation()
Loads the node translation for the specified language.
Parameters
\Drupal\node\NodeInterface $node: A node object.
string $langcode: The translation language code.
Return value
\Drupal\node\NodeInterface The node translation object.
2 calls to ModerationLocaleTest::loadTranslation()
- ModerationLocaleTest::testLanguageIndependentContentModeration in core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationLocaleTest.php - Tests that individual translations can be moderated independently.
- ModerationLocaleTest::testTranslationRevisionsHistory in core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationLocaleTest.php - Tests article revision history shows revisions for the correct translation.
File
-
core/
modules/ content_moderation/ tests/ src/ Functional/ ModerationLocaleTest.php, line 591
Class
- ModerationLocaleTest
- Test content_moderation functionality with localization and translation.
Namespace
Drupal\Tests\content_moderation\FunctionalCode
protected function loadTranslation(NodeInterface $node, $langcode) {
/** @var \Drupal\node\NodeStorageInterface $storage */
$storage = $this->container
->get('entity_type.manager')
->getStorage('node');
// Explicitly invalidate the cache for that node, as the call below is
// statically cached.
$storage->resetCache([
$node->id(),
]);
/** @var \Drupal\node\NodeInterface $node */
$node = $storage->loadRevision($storage->getLatestRevisionId($node->id()));
return $node->getTranslation($langcode);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.