public function LayoutBuilderForm::submitForm in Page Manager 8.4
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/ LayoutBuilderForm.php, line 119
Class
- LayoutBuilderForm
- Provides a form containing the Layout Builder UI for Page Manager.
Namespace
Drupal\page_manager\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$cached_values = $form_state
->getTemporaryValue('wizard');
/** @var \Drupal\page_manager\Entity\PageVariant $page_variant */
$page_variant = $this->sectionStorage
->getContextValue('entity');
// Pass down the variant settings and let the plugin handle saving it.
/** @var \Drupal\page_manager\Plugin\DisplayVariant\LayoutBuilderDisplayVariant $variant_plugin */
$variant_plugin = $cached_values['plugin'];
$variant_plugin
->setConfiguration($page_variant
->get('variant_settings'));
// The form wizard takes care of saving the variant.
// Clear the layout tempstore.
$this->layoutTempstoreRepository
->delete($this->sectionStorage);
$this
->messenger()
->addMessage($this
->t('The layout has been saved.'));
// Clean up the tempstore.
$this->tempstore
->get('page_manager.layout_builder')
->delete($page_variant
->id());
$this->tempstore
->get('page_manager.page_variant')
->delete($page_variant
->id());
}