protected function ContentTranslationFieldSyncRevisionTest::createRevision in Drupal 9
Same name and namespace in other branches
- 8 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::createRevision()
- 10 core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php \Drupal\Tests\content_translation\Kernel\ContentTranslationFieldSyncRevisionTest::createRevision()
Creates a new revision starting from the latest translation-affecting one.
Parameters
\Drupal\Core\Entity\ContentEntityInterface $translation: The translation to be revisioned.
bool $default: (optional) Whether the new revision should be marked as default. Defaults to TRUE.
Return value
\Drupal\Core\Entity\ContentEntityInterface An entity revision object.
1 call to ContentTranslationFieldSyncRevisionTest::createRevision()
- ContentTranslationFieldSyncRevisionTest::testFieldSynchronizationAndValidation in core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php - Checks that field synchronization works as expected with revisions.
File
- core/
modules/ content_translation/ tests/ src/ Kernel/ ContentTranslationFieldSyncRevisionTest.php, line 434
Class
- ContentTranslationFieldSyncRevisionTest
- Tests the field synchronization logic when revisions are involved.
Namespace
Drupal\Tests\content_translation\KernelCode
protected function createRevision(ContentEntityInterface $translation, $default = TRUE) {
if (!$translation
->isNewTranslation()) {
$langcode = $translation
->language()
->getId();
$revision_id = $this->storage
->getLatestTranslationAffectedRevisionId($translation
->id(), $langcode);
/** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
$revision = $this->storage
->loadRevision($revision_id);
$translation = $revision
->getTranslation($langcode);
}
/** @var \Drupal\Core\Entity\ContentEntityInterface $revision */
$revision = $this->storage
->createRevision($translation, $default);
return $revision;
}