public function createRevision(RevisionableInterface
$entity,
$default = TRUE,
$keep_untranslatable_fields = NULL
) { /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
$new_revision =
clone $entity;
$original_keep_untranslatable_fields =
$keep_untranslatable_fields;
// For translatable entities, create a merged revision of the active
// translation and the other translations in the default revision. This
// permits the creation of pending revisions that can always be saved as the
// new default revision without reverting changes in other languages.
if (!
$entity->
isNew() && !
$entity->
isDefaultRevision() &&
$entity->
isTranslatable() &&
$this->
isAnyRevisionTranslated($entity)) { $active_langcode =
$entity->
language()->
getId();
$skipped_field_names =
array_flip($this->
getRevisionTranslationMergeSkippedFieldNames());
// By default we copy untranslatable field values from the default
// revision, unless they are configured to affect only the default
// translation. This way we can ensure we always have only one affected
// translation in pending revisions. This constraint is enforced by
// EntityUntranslatableFieldsConstraintValidator.
if (!
isset($keep_untranslatable_fields)) { $keep_untranslatable_fields =
$entity->
isDefaultTranslation() &&
$entity->
isDefaultTranslationAffectedOnly();
}