You are here

public function Settings::submitForm in Courier 8

Same name in this branch
  1. 8 src/Form/Settings.php \Drupal\courier\Form\Settings::submitForm()
  2. 8 courier_system/src/Form/Settings.php \Drupal\courier_system\Form\Settings::submitForm()
Same name and namespace in other branches
  1. 2.x src/Form/Settings.php \Drupal\courier\Form\Settings::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/Settings.php, line 204

Class

Settings
Configure Courier settings.

Namespace

Drupal\courier\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('courier.settings');
  $channel_preferences = [];
  foreach ($form_state
    ->getValue('identity_types') as $identity_type => $settings) {
    foreach ($settings['channels'] as $channel => $row) {
      if (!empty($row['enabled'])) {
        $channel_preferences[$identity_type][] = $channel;
      }
    }
  }
  $config
    ->set('skip_queue', $form_state
    ->getValue('skip_queue'))
    ->set('channel_preferences', $channel_preferences)
    ->save();
  drupal_set_message(t('Settings saved.'));
}