You are here

public function ProtectedPagesSettingForm::submitForm in Protected Pages 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/ProtectedPagesSettingForm.php, line 241

Class

ProtectedPagesSettingForm
Provides protected pages settings configuration form.

Namespace

Drupal\protected_pages\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('protected_pages.settings');
  $config
    ->set('password.per_page_or_global', $form_state
    ->getValue('protected_pages_user_global_password'));
  $config
    ->set('password.protected_pages_session_expire_time', $form_state
    ->getValue('protected_pages_session_expire_time'));
  $config
    ->set('email.subject', $form_state
    ->getValue('protected_pages_email_subject'));
  $config
    ->set('email.body', $form_state
    ->getValue('protected_pages_email_body'));
  $config
    ->set('others.protected_pages_title', $form_state
    ->getValue('protected_pages_title'));
  $config
    ->set('others.protected_pages_description', $form_state
    ->getValue('protected_pages_description'));
  $config
    ->set('others.protected_pages_password_fieldset_legend', $form_state
    ->getValue('protected_pages_password_fieldset_legend'));
  $config
    ->set('others.protected_pages_password_label', $form_state
    ->getValue('protected_pages_password_label'));
  $config
    ->set('others.protected_pages_submit_button_text', $form_state
    ->getValue('protected_pages_submit_button_text'));
  $config
    ->set('others.protected_pages_incorrect_password_msg', $form_state
    ->getValue('protected_pages_incorrect_password_msg'));
  $password = $form_state
    ->getValue('protected_pages_global_password_field');
  if ($password) {
    $password_hash = $this->password
      ->hash(Html::escape($password));
    $config
      ->set('password.protected_pages_global_password', $password_hash);
  }
  $config
    ->save();
  drupal_flush_all_caches();
  return parent::submitForm($form, $form_state);
}