Import multiple paragraphs

Created on 17 May 2018, over 6 years ago
Updated 1 February 2019, almost 6 years ago

Hi, thanks for this module.
Do you think it would be possible to extend this module to import multiple values at once?

I think the concerned function is this one:

/**
   * Initiates an empty paragraph entity.
   *
   * @param object $entity
   *   The entity that is being edited.
   * @param array $mapping
   *   Contains the settings form fields values.
   * @param array $info
   *   The target field that is being mapped to.
   *
   * @return object
   *   The newly created paragraph item.
   */
  function feeds_para_mapper_get_init_para($entity, array $mapping, array $info) {
    $item = NULL;
    // Find out if we have previously saved paragraph.
    $has_para = isset($entity->{$mapping['selected_bundle']});
    if ($has_para) {
      // Get the current paragraph.
      $para_id = $entity->{$mapping['selected_bundle']}['und'][0]['value'];
      $para_entity = entity_load('paragraphs_item', [$para_id]);
      $item = reset($para_entity);
      $item->revision = TRUE;
      $item->default_revision = $item->revision_id;
    }
    if (!$item) {
      $correct_bundle = $info['bundles']['paragraphs_item'][0];
      $item = entity_create('paragraphs_item', [
        'bundle' => $correct_bundle,
        'field_name' => $mapping['selected_bundle'],
      ]);
    }
    return $item;
  }
Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇫🇷France elektrorl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024