function feeds_para_mapper_append_paragraphs in Feeds Paragraphs 7
Creates and updates new paragraphs entities when needed.
Creates and marks other paragraphs entities for values changes.
Parameters
object $entity: The entity that is being edited or created.
array $mapping: Information about the target field and the target paragraph.
array $entities: The existing Paragraphs entities that are attached to the $entity.
array $slices: The sliced values based on user choice & the field cardinality.
Return value
array The newly created and updated entities.
1 call to feeds_para_mapper_append_paragraphs()
- 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 819 - Allows feeds to import content to Paragraphs' fields.
Code
function feeds_para_mapper_append_paragraphs($entity, array $mapping, array $entities, array $slices) {
$items = array();
$slices = feeds_para_mapper_check_values_changes($mapping, $slices, $entities);
for ($i = 0; $i < count($slices); $i++) {
$state = $slices[$i]['state'];
unset($slices[$i]['state']);
$last_item = $entities[count($entities) - 1];
if ($state === 'new') {
// Instead of creating another series of host entity/entities,
// duplicate the last created host entity:
$par = feeds_para_mapper_duplicate_existing($mapping, $entity, $last_item);
$items[] = array(
'paragraph' => $par,
'value' => $slices[$i],
);
}
else {
$items[] = array(
'paragraph' => $entities[$i],
'value' => $slices[$i],
);
}
}
return $items;
}