You are here

public function MenuManipulatorSettingsForm::submitForm in Menu Manipulator 3.0.x

Same name and namespace in other branches
  1. 8.2 src/Form/MenuManipulatorSettingsForm.php \Drupal\menu_manipulator\Form\MenuManipulatorSettingsForm::submitForm()
  2. 8 src/Form/MenuManipulatorSettingsForm.php \Drupal\menu_manipulator\Form\MenuManipulatorSettingsForm::submitForm()
  3. 2.0.x src/Form/MenuManipulatorSettingsForm.php \Drupal\menu_manipulator\Form\MenuManipulatorSettingsForm::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 ConfigFormBase::submitForm

File

src/Form/MenuManipulatorSettingsForm.php, line 215

Class

MenuManipulatorSettingsForm
Configure custom settings for Menu Manipulators.

Namespace

Drupal\menu_manipulator\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('menu_manipulator.settings');
  $exclude = [
    'submit',
    'form_build_id',
    'form_token',
    'form_id',
    'op',
  ];
  foreach ($form_state
    ->getValues() as $key => $data) {
    if (!in_array($key, $exclude)) {
      $config
        ->set($key, $data);
    }
  }
  $config
    ->save();
  parent::submitForm($form, $form_state);

  // Invalidate the menu cache.
  $this->menuCacheBackend
    ->invalidateAll();

  // Invalidate the block cache to update menu-based derivatives.
  if ($this->blockManager instanceof BlockManagerInterface) {
    $this->blockManager
      ->clearCachedDefinitions();
  }
}