You are here

function feeds_para_mapper_init_mapping in Feeds Paragraphs 7

Initializes the mapping array.

Parameters

object $entity: The entity that is being edited or created.

array $mapping: Information about the target field and the target paragraph.

Return value

array The final mapping array.

1 call to feeds_para_mapper_init_mapping()
feeds_para_mapper_set_target in ./feeds_para_mapper.module
Sets the values for the target field.

File

./feeds_para_mapper.module, line 595
Allows feeds to import content to Paragraphs' fields.

Code

function feeds_para_mapper_init_mapping($entity, array $mapping) {
  $type = $entity->feeds_item->entity_type;
  $bundle = $entity->type;

  // Get list of the target fields.
  $cache =& drupal_static(__FUNCTION__);
  if (!isset($cache['targets'])) {

    // If the list is not cached, add it to cache.
    $cache['targets'] = feeds_para_mapper_feeds_processor_targets($type, $bundle, TRUE);
  }

  // Search for the current target in the list.
  $targets = $cache['targets'];
  $f_target = NULL;
  foreach ($targets as $name => $item) {
    if ($name === $mapping['target']) {
      $f_target = $item;
    }
  }

  // Add some required information to $mapping.
  $mapping['ctype_field'] = $f_target['ctype_field'];
  $mapping['paragraph_bundle'] = $f_target['paragraph_bundle'];
  $mapping['field'] = $f_target['machine_name'];
  $mapping['module'] = $f_target['module'];
  $mapping['type'] = $f_target['type'];
  $mapping['module_callback'] = $f_target['module_callback'];
  if (isset($f_target['real_target'])) {
    $mapping['real_target'] = $f_target['real_target'];
  }
  if (isset($f_target['path'])) {
    $mapping['path'] = $f_target['path'];
  }
  if (isset($f_target['in_common'])) {
    $mapping['in_common'] = $f_target['in_common'];
  }
  $mapping['max_values'] = feeds_para_mapper_get_max_values($mapping['field'], $mapping);
  if (isset($f_target['host_field'])) {
    $mapping['host_field'] = $f_target['host_field'];
  }
  return $mapping;
}