private function Importer::appendParagraphs in Feeds Paragraphs 8
Creates and updates new paragraphs entities when needed.
Creates and marks other paragraphs entities for values changes.
Parameters
Paragraph[] $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 Importer::appendParagraphs()
- Importer::initHostParagraphs in src/
Importer.php - Creates empty host Paragraphs entities or gets the existing ones.
File
- src/
Importer.php, line 421
Class
Namespace
Drupal\feeds_para_mapperCode
private function appendParagraphs(array $entities, array $slices) {
$items = array();
$slices = $this
->checkValuesChanges($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:
$paragraph = $this
->duplicateExisting($last_item);
}
else {
$paragraph = $entities[$i];
}
$items[] = array(
'paragraph' => $paragraph,
'value' => $slices[$i],
'state' => $state,
);
}
return $items;
}