You are here

function paragraphs_field_prepare_translation in Paragraphs 7

Implements hook_field_prepare_translation().

See also

field_attach_prepare_translation()

File

./paragraphs.module, line 1430
Paragraphs hooks and common functions.

Code

function paragraphs_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
  if (!module_exists("paragraphs_i18n")) {
    list($id, , ) = entity_extract_ids($entity_type, $entity);

    // field_attach_prepare_translation() copied the entity ids from the source,
    // as we need a new entity for a new translation, we cannot reuse that.
    // @todo clone existing paragraphs to new translation
    if (empty($id)) {
      $items = array();
    }
  }
  else {
    paragraphs_i18n_field_prepare_translation($entity_type, $entity, $field, $instance, $langcode, $items, $source_entity, $source_langcode);
  }
}