You are here

public function EmailConfirmerSettingsForm::submitForm in Email confirmer 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/EmailConfirmerSettingsForm.php, line 252

Class

EmailConfirmerSettingsForm
Email confirmer settings form.

Namespace

Drupal\email_confirmer\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('email_confirmer.settings');
  foreach ([
    'pending',
    'expired',
    'cancelled',
    'confirmed',
  ] as $status) {
    $config
      ->set('confirmation_response.questions.' . $status, $form_state
      ->getValue('confirmationresponse_' . $status));
  }
  $config
    ->set('hash_expiration', intval($form_state
    ->getValue('hash_expiration')) * self::SECONDS_PER_HOUR)
    ->set('confirmation_lifetime', intval($form_state
    ->getValue('confirmation_lifetime')) * self::SECONDS_PER_WEEK)
    ->set('restrict_same_ip', $form_state
    ->getValue('restrict_same_ip') || FALSE)
    ->set('resendrequest_delay', intval($form_state
    ->getValue('resendrequest_delay')) * 60)
    ->set('confirmation_request.subject', $form_state
    ->getValue('confirmationrequest_subject'))
    ->set('confirmation_request.body', $form_state
    ->getValue('confirmationrequest_body'))
    ->set('confirmation_response.skip_confirmation_form', $form_state
    ->getValue('confirmationresponse_skipform') || FALSE)
    ->set('confirmation_response.url.confirm', $form_state
    ->getValue('confirmationresponse_url_confirm'))
    ->set('confirmation_response.url.cancel', $form_state
    ->getValue('confirmationresponse_url_cancel'))
    ->set('confirmation_response.url.error', $form_state
    ->getValue('confirmationresponse_url_error'))
    ->save();
  parent::submitForm($form, $form_state);
}