You are here

public function AdvbanDelete::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/AdvbanDelete.php, line 113

Class

AdvbanDelete
Provides a form to unban IP addresses.

Namespace

Drupal\advban\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $this->ipManager
    ->unbanIp($this->banIp, $this->banIpEnd);
  $formatIp = $this->ipManager
    ->formatIp($this->banIp, $this->banIpEnd);
  $this
    ->logger('advanced ban')
    ->notice('Deleted %ip', [
    '%ip' => $formatIp,
  ]);
  $this
    ->messenger()
    ->addMessage($this
    ->t('The IP address(es) %ip was deleted.', [
    '%ip' => $formatIp,
  ]));
  $form_state
    ->setRedirectUrl($this
    ->getCancelUrl());
}