You are here

public function SettingsForm::submitForm in Auto Purge Users 8

Same name and namespace in other branches
  1. 8.3 src/Form/SettingsForm.php \Drupal\purge_users\Form\SettingsForm::submitForm()
  2. 8.2 src/Form/SettingsForm.php \Drupal\purge_users\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 305

Class

SettingsForm
Class SettingsForm.

Namespace

Drupal\purge_users\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  parent::submitForm($form, $form_state);
  $this
    ->config('purge_users.settings')
    ->set('user_never_lastlogin_value', $form_state
    ->getValue('user_never_lastlogin_value'))
    ->set('user_never_lastlogin_period', $form_state
    ->getValue('user_never_lastlogin_period'))
    ->set('user_lastlogin_value', $form_state
    ->getValue('user_lastlogin_value'))
    ->set('user_lastlogin_period', $form_state
    ->getValue('user_lastlogin_period'))
    ->set('user_inactive_value', $form_state
    ->getValue('user_inactive_value'))
    ->set('user_inactive_period', $form_state
    ->getValue('user_inactive_period'))
    ->set('user_blocked_value', $form_state
    ->getValue('user_blocked_value'))
    ->set('user_blocked_period', $form_state
    ->getValue('user_blocked_period'))
    ->set('enabled_never_loggedin_users', $form_state
    ->getValue('enabled_never_loggedin_users'))
    ->set('enabled_loggedin_users', $form_state
    ->getValue('enabled_loggedin_users'))
    ->set('enabled_inactive_users', $form_state
    ->getValue('enabled_inactive_users'))
    ->set('enabled_blocked_users', $form_state
    ->getValue('enabled_blocked_users'))
    ->set('purge_users_roles', $form_state
    ->getValue('purge_users_roles'))
    ->set('purge_on_cron', $form_state
    ->getValue('purge_on_cron'))
    ->set('inactive_user_notify_text', $form_state
    ->getValue('inactive_user_notify_text'))
    ->set('send_email_notification', $form_state
    ->getValue('send_email_notification'))
    ->set('purge_user_cancel_method', $form_state
    ->getValue('purge_user_cancel_method'))
    ->save();
  if ($form_state
    ->getValue('purge_on_cron') == 1) {
    drupal_set_message($this
      ->t('Purge users operation is scheduled for next cron.'));
  }
}