You are here

public function EmaillogConfigForm::submitForm in Logging and alerts 8

Same name and namespace in other branches
  1. 2.0.x emaillog/src/Form/EmaillogConfigForm.php \Drupal\emaillog\Form\EmaillogConfigForm::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

emaillog/src/Form/EmaillogConfigForm.php, line 194

Class

EmaillogConfigForm
Provides a setting UI for emaillog.

Namespace

Drupal\emaillog\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $userInputValues = $form_state
    ->getUserInput();
  $config = $this
    ->config('emaillog.settings');
  $severity_levels = RfcLogLevel::getLevels();
  $debug_info = [];
  foreach (array_keys($severity_levels) as $level_id) {
    foreach (array_keys(_emaillog_get_debug_info_callbacks()) as $variable_id) {
      if (!empty($userInputValues['debug_info'][$level_id][$variable_id])) {
        $debug_info[$level_id][$variable_id] = 1;
      }
    }
  }
  foreach (array_keys($severity_levels) as $level_id) {
    $config
      ->set('emaillog_' . $level_id, $userInputValues['emaillog_' . $level_id]);
  }
  $config
    ->set('emaillog_backtrace_replace_args', $userInputValues['debug_info']['emaillog_backtrace_replace_args']);
  $config
    ->set('emaillog_debug_info', $debug_info);
  $config
    ->set('emaillog_max_similar_emails', $userInputValues['emaillog_max_similar_emails']);
  $config
    ->set('emaillog_max_consecutive_timespan', $userInputValues['emaillog_max_consecutive_timespan']);
  $config
    ->set('emaillog_max_similarity_level', $userInputValues['emaillog_max_similarity_level']);
  $config
    ->set('emaillog_legacy_subject', $userInputValues['emaillog_legacy_subject']);
  $config
    ->save();
}