Submit the values taken from the form to store the values.
This method is responsible for submitting the data and saving it in the paragraphs entity.
array $settings: The conversion settings to be applied.
\Drupal\paragraphs\ParagraphInterface $original_paragraph: The original paragraph to convert.
array $converted_paragraphs: (optional) The array of converted paragraphs.
Overrides ParagraphsConversionBase::convert
public function convert(array $settings, ParagraphInterface $original_paragraph, array $converted_paragraphs = NULL) {
$username = "Empty user field";
if ($original_paragraph
->get('field_user_demo')->entity) {
$username = $original_paragraph
->get('field_user_demo')->entity
->label();
}
$converted_paragraphs = [
[
'type' => 'text',
'field_text_demo' => [
'value' => $username,
],
],
];
if ($settings['multiple']) {
$converted_paragraphs[] = [
'type' => 'text',
'field_text_demo' => [
'value' => $username,
],
];
}
return $converted_paragraphs;
}