protected function ContentEntitySource::createTranslationDuplicate

Creates a translation duplicate of the given entity.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $target_entity: The target entity to clone.

string $langcode: Language code for all the clone entities created.

Return value

\Drupal\Core\Entity\ContentEntityInterface New entity object with the data from the original entity. Not saved. No sub-entities are cloned.

1 call to ContentEntitySource::createTranslationDuplicate()
ContentEntitySource::doSaveTranslations in sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php
Saves translation data in an entity translation.

File

sources/content/src/Plugin/tmgmt/Source/ContentEntitySource.php, line 631

Class

ContentEntitySource
Content entity source plugin controller.

Namespace

Drupal\tmgmt_content\Plugin\tmgmt\Source

Code

protected function createTranslationDuplicate(ContentEntityInterface $target_entity, $langcode) {
  $duplicate = $target_entity
    ->createDuplicate();

  // Change the original language.
  if ($duplicate
    ->getEntityType()
    ->hasKey('langcode')) {
    $duplicate
      ->set($duplicate
      ->getEntityType()
      ->getKey('langcode'), $langcode);
  }
  return $duplicate;
}