You are here

public function RevertOverridesForm::submitForm in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/src/Form/RevertOverridesForm.php \Drupal\layout_builder\Form\RevertOverridesForm::submitForm()
  2. 10 core/modules/layout_builder/src/Form/RevertOverridesForm.php \Drupal\layout_builder\Form\RevertOverridesForm::submitForm()

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

core/modules/layout_builder/src/Form/RevertOverridesForm.php, line 110

Class

RevertOverridesForm
Reverts the overridden layout to the defaults.

Namespace

Drupal\layout_builder\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // Remove all sections.
  $this->sectionStorage
    ->removeAllSections()
    ->save();
  $this->layoutTempstoreRepository
    ->delete($this->sectionStorage);
  $this->messenger
    ->addMessage($this
    ->t('The layout has been reverted back to defaults.'));
  $form_state
    ->setRedirectUrl($this->sectionStorage
    ->getRedirectUrl());
}