You are here

function entity_translation_entity_uuid_presave in Entity Translation 7

Implements hook_entity_uuid_presave().

File

./entity_translation.module, line 2041

Code

function entity_translation_entity_uuid_presave(&$entity, $entity_type) {

  // UUID exports entities as arrays, therefore we need to cast the translations
  // array back into an object.
  $entity_info = entity_get_info($entity_type);
  if (isset($entity_info['entity keys']) && isset($entity_info['entity keys']['translations'])) {
    $key = $entity_info['entity keys']['translations'];
    if (isset($entity->{$key})) {
      $entity->{$key} = (object) $entity->{$key};
    }
  }
}