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";
$user = NULL;
if ($original_paragraph
->get('field_user_demo')->entity) {
$username = $original_paragraph
->get('field_user_demo')->entity
->label();
$user = $original_paragraph
->get('field_user_demo')->entity;
}
return [
[
'type' => 'text',
'field_text_demo' => [
'value' => $username,
],
],
[
'type' => 'user',
'field_user_demo' => $user ?: NULL,
],
];
}