You are here

public function MailgunAdminSettingsForm::submitForm in Mailgun 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/MailgunAdminSettingsForm.php, line 255

Class

MailgunAdminSettingsForm
Provides Mailgun configuration form.

Namespace

Drupal\mailgun\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config_keys = [
    'working_domain',
    'api_key',
    'debug_mode',
    'test_mode',
    'tracking_opens',
    'tracking_clicks',
    'tracking_exception',
    'format_filter',
    'use_queue',
    'use_theme',
    'tagging_mailkey',
    'api_endpoint',
  ];
  $mailgun_config = $this
    ->config(MailgunHandlerInterface::CONFIG_NAME);
  foreach ($config_keys as $config_key) {
    if ($form_state
      ->hasValue($config_key)) {
      $mailgun_config
        ->set($config_key, $form_state
        ->getValue($config_key));
    }
  }
  $mailgun_config
    ->save();
  $this
    ->messenger()
    ->addMessage($this
    ->t('The configuration options have been saved.'));
}