You are here

public function SettingsForm::submitForm in Build Hooks 8

Same name and namespace in other branches
  1. 8.2 src/Form/SettingsForm.php \Drupal\build_hooks\Form\SettingsForm::submitForm()
  2. 3.x src/Form/SettingsForm.php \Drupal\build_hooks\Form\SettingsForm::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/SettingsForm.php, line 136

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\build_hooks\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $config = $this
    ->config('build_hooks.settings');
  $config
    ->set('build_hook', $form_state
    ->getValue('build_hook'));
  $config
    ->set('messages.log', $form_state
    ->getValue('log'));
  $config
    ->set('messages.show', $form_state
    ->getValue('show'));
  $config
    ->set('triggers.cron', $form_state
    ->getValue('cron'));
  $config
    ->set('triggers.menu', $form_state
    ->getValue('menu'));
  foreach ($this
    ->getNodeTypes() as $nodeType) {
    $config
      ->set('triggers.node.' . $nodeType
      ->id(), $form_state
      ->getValue('node_type_' . $nodeType
      ->id()));
  }
  $config
    ->save();
}