protected function EntityProcessorBase::createNewTranslation in Content Synchronizer 8.2
Same name and namespace in other branches
- 8 src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::createNewTranslation()
- 3.x src/Processors/Entity/EntityProcessorBase.php \Drupal\content_synchronizer\Processors\Entity\EntityProcessorBase::createNewTranslation()
Return a translation.
Parameters
string $languageId: The language id.
\Drupal\Core\Entity\EntityInterface $existingEntity: The entity to translate.
array $dataToImport: The data to import.
1 call to EntityProcessorBase::createNewTranslation()
- EntityProcessorBase::getEntityToImport in src/
Processors/ Entity/ EntityProcessorBase.php - Return the entity to import.
File
- src/
Processors/ Entity/ EntityProcessorBase.php, line 184
Class
- EntityProcessorBase
- The entity processor base.
Namespace
Drupal\content_synchronizer\Processors\EntityCode
protected function createNewTranslation($languageId, EntityInterface $existingEntity, array $dataToImport = []) {
// If the entity is translatable.
if ($existingEntity
->isTranslatable()) {
if ($existingEntity
->language()
->getId() == $languageId) {
return $existingEntity;
}
else {
$translation = $existingEntity
->addTranslation($languageId);
$translation->uuid = \Drupal::service('uuid')
->generate();
return $translation;
}
}
else {
/* If the entity is not translatable we create a default translation if the curent language is the default one. */
if ($existingEntity
->isDefaultTranslation()) {
return $existingEntity;
}
}
// If the entity is not translatable and the current languageId is not the entity default language,
// then it seems that configuration is not the same as the export environement
// sor the translation is not imported.
return NULL;
}