public function EntityTranslationDefaultHandler::initOriginalTranslation in Entity Translation 7
Overrides EntityTranslationHandlerInterface::initOriginalTranslation
See also
EntityTranslationHandlerInterface::initOriginalTranslation()
File
- includes/
translation.handler.inc, line 811 - Default translation handler for the translation module.
Class
- EntityTranslationDefaultHandler
- Class implementing the default entity translation behaviours.
Code
public function initOriginalTranslation() {
$fixed = FALSE;
$translations = $this
->getTranslations();
foreach (field_info_instances($this->entityType, $this->bundle) as $instance) {
$field_name = $instance['field_name'];
$field = field_info_field($field_name);
$langcode = count($this->entity->{$field_name}) == 1 ? key($this->entity->{$field_name}) : $translations->original;
if ($langcode == LANGUAGE_NONE && $field['translatable']) {
$this->entity->{$field_name}[$translations->original] = $this->entity->{$field_name}[$langcode];
$this->entity->{$field_name}[$langcode] = array();
$fixed = TRUE;
}
}
return $fixed;
}