You are here

public function TranslatableStorageInterface::createTranslation in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/TranslatableStorageInterface.php \Drupal\Core\Entity\TranslatableStorageInterface::createTranslation()
  2. 10 core/lib/Drupal/Core/Entity/TranslatableStorageInterface.php \Drupal\Core\Entity\TranslatableStorageInterface::createTranslation()

Constructs a new entity translation object, without permanently saving it.

@todo Consider accepting \Drupal\Core\Entity\TranslatableInterface as first parameter. See https://www.drupal.org/project/drupal/issues/2932049.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity object being translated.

string $langcode: The translation language code.

array $values: (optional) An associative array of initial field values keyed by field name. If none is provided default values will be applied.

Return value

\Drupal\Core\Entity\ContentEntityInterface Another instance of the specified entity object class with the specified active language and initial values.

2 methods override TranslatableStorageInterface::createTranslation()
ContentEntityStorageBase::createTranslation in core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php
Constructs a new entity translation object, without permanently saving it.
KeyValueContentEntityStorage::createTranslation in core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueContentEntityStorage.php
Constructs a new entity translation object, without permanently saving it.

File

core/lib/Drupal/Core/Entity/TranslatableStorageInterface.php, line 28

Class

TranslatableStorageInterface
A storage that supports translatable entity types.

Namespace

Drupal\Core\Entity

Code

public function createTranslation(ContentEntityInterface $entity, $langcode, array $values = []);