You are here

public function DomainMenuAccessSettingsForm::submitForm in Domain Menu Access 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 ConfigFormBase::submitForm

File

src/Form/DomainMenuAccessSettingsForm.php, line 61

Class

DomainMenuAccessSettingsForm

Namespace

Drupal\domain_menu_access\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('domain_menu_access.settings');
  $menu = array_keys(Menu::loadMultiple());
  if (!empty($menu) && !empty($form_state
    ->getValues())) {
    $menu_enabled = [];
    $values = $form_state
      ->getValues();
    foreach ($values as $key => $value) {
      if ($value && in_array($key, $menu)) {
        $menu_enabled[] = $key;
      }
    }
    $config
      ->set('menu_enabled', $menu_enabled);
    $config
      ->save();
  }
  parent::submitForm($form, $form_state);
}