You are here

public function AdminSettingsForm::submitForm in SMS Framework 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

modules/sms_user/src/Form/AdminSettingsForm.php, line 431

Class

AdminSettingsForm
Provides a general settings form for SMS User.

Namespace

Drupal\sms_user\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('sms_user.settings');

  // Account Registration.
  $account_registration = $form_state
    ->getValue('account_registration');
  $behaviour = $account_registration['behaviour'];
  $config
    ->set('account_registration.unrecognized_sender.status', $behaviour == 'all')
    ->set('account_registration.incoming_pattern.status', $behaviour == 'incoming_pattern')
    ->set('account_registration.unrecognized_sender.reply.status', $account_registration['all_options']['reply_status'])
    ->set('account_registration.unrecognized_sender.reply.message', $account_registration['all_options']['reply']['message'])
    ->set('account_registration.incoming_pattern.incoming_messages.0', $account_registration['incoming_pattern_options']['incoming_message'])
    ->set('account_registration.incoming_pattern.reply.status', $account_registration['incoming_pattern_options']['reply_status'])
    ->set('account_registration.incoming_pattern.reply.message', $account_registration['incoming_pattern_options']['reply']['message_success'])
    ->set('account_registration.incoming_pattern.reply.message_failure', $account_registration['incoming_pattern_options']['reply']['message_failure'])
    ->set('account_registration.incoming_pattern.send_activation_email', $account_registration['incoming_pattern_options']['send_activation_email'])
    ->set('active_hours.status', (bool) $form_state
    ->getValue([
    'active_hours',
    'status',
  ]))
    ->set('active_hours.ranges', array_values($form_state
    ->getValue([
    'active_hours',
    'days',
  ])))
    ->save();
  parent::submitForm($form, $form_state);
}