public function ParagraphTypeGroupsForm::submitForm in Paragraphs Browser 8
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ ParagraphTypeGroupsForm.php, line 136 - Contains \Drupal\paragraphs_browser\Form\ParagraphsTypeGroupForm.
Class
- ParagraphTypeGroupsForm
- Class CleanupUrlAliases.
Namespace
Drupal\paragraphs_browser\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$build_info = $form_state
->getBuildInfo();
$paragraph_browser_types = $build_info['paragraph_browser_types'];
$paragraph_type = $build_info['paragraph_type'];
$mapping = $form_state
->getValue('paragraph_browser_type');
$mapping = array_combine(array_keys($mapping), array_column($mapping, 'group'));
$mapping = array_filter($mapping, function ($v, $k) {
return $v != '_na';
}, ARRAY_FILTER_USE_BOTH);
foreach ($paragraph_browser_types as $paragraph_browser_type_id => $paragraph_browser_type) {
$paragraph_browser_type
->removeGroupMap($paragraph_type
->id());
if (isset($mapping[$paragraph_browser_type_id])) {
$paragraph_browser_type
->setGroupMap($paragraph_type
->id(), $mapping[$paragraph_browser_type_id]);
}
}
$this->messenger
->addMessage($this
->t('The selected groups have been added to the %label Paragraph type.', array(
'%label' => $paragraph_type
->label(),
)));
}