You are here

public function AdvbanDeleteAll::submitForm in Advanced ban 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 FormInterface::submitForm

File

src/Form/AdvbanDeleteAll.php, line 88

Class

AdvbanDeleteAll
Provides a form to unban IP addresses.

Namespace

Drupal\advban\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $params = [
    'range' => $form_state
      ->getValue('advban_delete_range'),
    'expire' => $form_state
      ->getValue('advban_delete_expire'),
  ];
  $deleted = $this->ipManager
    ->unbanIpAll($params);
  if ($deleted > 0) {
    $this
      ->logger('advanced ban')
      ->notice('Deleted all IP');
    $this
      ->messenger()
      ->addMessage($this
      ->t('Checked IP addresses groups were deleted.'));
  }
  else {
    $this
      ->messenger()
      ->addMessage($this
      ->t('No IP addresses for delete.'));
  }
}