protected function ComponentFormBase::buildParagraphComponent in Layout Paragraphs 2.0.x
Builds the paragraph component using submitted form values.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The form state object.
Return value
\Drupal\paragraphs\Entity\Paragraph The paragraph entity.
2 calls to ComponentFormBase::buildParagraphComponent()
- ComponentFormBase::submitForm in src/
Form/ ComponentFormBase.php - Saves the paragraph component.
- ComponentFormBase::validateForm in src/
Form/ ComponentFormBase.php - Validate the component form.
File
- src/
Form/ ComponentFormBase.php, line 285
Class
- ComponentFormBase
- Class LayoutParagraphsComponentFormBase.
Namespace
Drupal\layout_paragraphs\FormCode
protected function buildParagraphComponent(array $form, FormStateInterface $form_state) {
/** @var Drupal\Core\Entity\Entity\EntityFormDisplay $display */
$display = $form['#display'];
$paragraph = clone $this->paragraph;
$paragraph
->getAllBehaviorSettings();
$paragraphs_type = $paragraph
->getParagraphType();
if ($paragraphs_type
->hasEnabledBehaviorPlugin('layout_paragraphs')) {
$layout_paragraphs_plugin = $paragraphs_type
->getEnabledBehaviorPlugins()['layout_paragraphs'];
$subform_state = SubformState::createForSubform($form['layout_paragraphs'], $form, $form_state);
$layout_paragraphs_plugin
->submitBehaviorForm($paragraph, $form['layout_paragraphs'], $subform_state);
}
foreach ($this
->getEnabledBehaviorPlugins() as $behavior_id => $behavior_plugin) {
$subform_state = SubformState::createForSubform($form['behavior_plugins'][$behavior_id], $form, $form_state);
$behavior_plugin
->submitBehaviorForm($paragraph, $form['behavior_plugins'][$behavior_id], $subform_state);
}
$paragraph
->setNeedsSave(TRUE);
$display
->extractFormValues($paragraph, $form, $form_state);
return $paragraph;
}