public function Settings::submitForm in Courier 2.x
Same name in this branch
- 2.x src/Form/Settings.php \Drupal\courier\Form\Settings::submitForm()
- 2.x courier_system/src/Form/Settings.php \Drupal\courier_system\Form\Settings::submitForm()
Same name and namespace in other branches
- 8 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\FormCode
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();
$this
->messenger()
->addMessage($this
->t('Settings saved.'));
}