You are here

function feeds_para_mapper_get_attached in Feeds Paragraphs 7

Finds the attached paragraphs whether they are in db or just temporary attached.

Parameters

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

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

bool $emptyOnly: If true, we return entities where the target field is empty, otherwise we return all.

bool $firstResult: If true, we return the first attached paragraph entity (first parent paragraph).

Return value

array

1 call to feeds_para_mapper_get_attached()
feeds_para_mapper_init_host_paragraphs in ./feeds_para_mapper.module
Creates empty host Paragraphs entities or gets the existing ones.

File

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

Code

function feeds_para_mapper_get_attached($entity, $mapping, $emptyOnly = FALSE, $firstResult = FALSE) {

  // If the node entity is new, find the attached (non-saved) Paragraphs:
  if ($entity->feeds_item->is_new) {

    // Get the existing Paragraphs entity:
    $attached = feeds_para_mapper_get_target_paragraph($entity, $mapping, $emptyOnly, $firstResult);
  }
  else {

    // Load existing paragraph:
    // @todo: pass and handle the rest of params
    $attached = feeds_para_mapper_load_target_paragraph($entity, $mapping);
  }
  return $attached;
}