You are here

public function SettingsForm::submitForm in Automatic Updates 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/SettingsForm.php, line 215

Class

SettingsForm
Settings form for automatic updates.

Namespace

Drupal\automatic_updates\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $form_state
    ->cleanValues();
  $config = $this
    ->config('automatic_updates.settings');
  foreach ($form_state
    ->getValues() as $key => $value) {
    $config
      ->set($key, $value);

    // Disable cron automatic updates if readiness checks are disabled.
    if (in_array($key, [
      'enable_cron_updates',
      'enable_cron_security_updates',
    ], TRUE) && !$form_state
      ->getValue('enable_readiness_checks')) {
      $config
        ->set($key, FALSE);
    }
  }
  $config
    ->save();
}