unbanIp example

public function buildForm(array $form, FormStateInterface $form_state$ban_id = '') {
    if (!$this->banIp = $this->ipManager->findById($ban_id)) {
      throw new NotFoundHttpException();
    }
    return parent::buildForm($form$form_state);
  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->ipManager->unbanIp($this->banIp);
    $this->logger('user')->notice('Deleted %ip', ['%ip' => $this->banIp]);
    $this->messenger()->addStatus($this->t('The IP address %ip was deleted.', ['%ip' => $this->banIp]));
    $form_state->setRedirectUrl($this->getCancelUrl());
  }

}
Home | Imprint | This part of the site doesn't use cookies.