You are here

public function SettingsForm::submitForm in Session Limit 8

Same name and namespace in other branches
  1. 2.x src/Form/SettingsForm.php \Drupal\session_limit\Form\SettingsForm::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/SettingsForm.php, line 110

Class

SettingsForm

Namespace

Drupal\session_limit\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $config = $this
    ->config('session_limit.settings');
  $config
    ->set('session_limit_max', $form_state
    ->getValue($form['session_limit_max']['#parents']));
  $config
    ->set('session_limit_behaviour', $form_state
    ->getValue($form['session_limit_behaviour']['#parents']));
  $config
    ->set('session_limit_logged_out_message_severity', $form_state
    ->getValue($form['session_limit_logged_out_message_severity']['#parents']));
  $role_limits = [];
  foreach (user_roles(TRUE) as $rid => $role) {
    $role_limits[$rid] = $form_state
      ->getValue($form['session_limit_roles'][$rid]['#parents']);
  }
  $config
    ->set('session_limit_roles', $role_limits);
  if (!empty($form['session_limit_masquerade_ignore'])) {
    $config
      ->set('session_limit_masquerade_ignore', $form_state
      ->getValue($form['session_limit_masquerade_ignore']['#parents']));
  }
  $config
    ->save();
  if (method_exists($this, '_submitForm')) {
    $this
      ->_submitForm($form, $form_state);
  }
  parent::submitForm($form, $form_state);
}