protected function ContentEntityBase::initializeTranslation in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/ContentEntityBase.php \Drupal\Core\Entity\ContentEntityBase::initializeTranslation()
Instantiates a translation object for an existing translation.
The translated entity will be a clone of the current entity with the specified $langcode. All translations share the same field data structures to ensure that all of them deal with fresh data.
Parameters
string $langcode: The language code for the requested translation.
Return value
\Drupal\Core\Entity\EntityInterface The translation object. The content properties of the translation object are stored as references to the main entity.
1 call to ContentEntityBase::initializeTranslation()
- ContentEntityBase::getTranslation in core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php - Gets a translation of the data.
File
- core/
lib/ Drupal/ Core/ Entity/ ContentEntityBase.php, line 775 - Contains \Drupal\Core\Entity\ContentEntityBase.
Class
- ContentEntityBase
- Implements Entity Field API specific enhancements to the Entity class.
Namespace
Drupal\Core\EntityCode
protected function initializeTranslation($langcode) {
// If the requested translation is valid, clone it with the current language
// as the active language. The $translationInitialize flag triggers a
// shallow (non-recursive) clone.
$this->translationInitialize = TRUE;
$translation = clone $this;
$this->translationInitialize = FALSE;
$translation->activeLangcode = $langcode;
// Ensure that changes to fields, values and translations are propagated
// to all the translation objects.
// @todo Consider converting these to ArrayObject.
$translation->values =& $this->values;
$translation->fields =& $this->fields;
$translation->translations =& $this->translations;
$translation->enforceIsNew =& $this->enforceIsNew;
$translation->newRevision =& $this->newRevision;
$translation->entityKeys =& $this->entityKeys;
$translation->translatableEntityKeys =& $this->translatableEntityKeys;
$translation->translationInitialize = FALSE;
$translation->typedData = NULL;
return $translation;
}