Commit 27b793b9 authored by mistermoper's avatar mistermoper

Allow don't map a paragraph field key, just set the value directly.

parent 51e7054c
......@@ -40,7 +40,7 @@ class ParagraphItem extends ProcessPluginBase {
$source_id = $this->getSourceIdUniqueValue($row);
$paragraph_field = $this->configuration['paragraph_field'];
$paragraph_field_key = $this->configuration['paragraph_field_key'];
$paragraph_field_key = !empty($this->configuration['paragraph_field_key']) ? $this->configuration['paragraph_field_key'] : NULL;
// @TODO: handle delta control in separate method!
$delta_paragraph = $this->getParagraphDelta($source_id, $paragraph_field);
......@@ -50,15 +50,29 @@ class ParagraphItem extends ProcessPluginBase {
}
foreach ($value as $delta => $item) {
$paragraph = NULL;
if (!is_null($item)) {
if ($this->multiple() && !$this->splitOnMultiple()) {
$paragraph = $this->getParagraph($source_id, $destination_property, $delta_paragraph);
$paragraph->{$paragraph_field}->set($delta, [$paragraph_field_key => $item]);
$value = !empty($paragraph_field_key) ? [$paragraph_field_key => $item] : $item;
$paragraph->{$paragraph_field}->set($delta, $value);
$paragraph->save();
}
else {
$paragraph = $this->getParagraph($source_id, $destination_property, $delta);
$paragraph->{$paragraph_field}->{$paragraph_field_key} = $item;
if (!empty($paragraph_field_key)) {
$paragraph->{$paragraph_field}->{$paragraph_field_key} = $item;
}
else {
if (is_array($item)) {
foreach ($item as $property => $property_value) {
$paragraph->{$paragraph_field}->{$property} = $property_value;
}
}
else {
$paragraph->{$paragraph_field} = $item;
}
}
$paragraph->save();
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment