public function BanSubscriber::onKernelRequestBannedIpCheck

Response with 403 if the visitor's IP adress is banned.

Parameters

Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The Event to process.

File

drupal/core/modules/ban/lib/Drupal/ban/EventSubscriber/BanSubscriber.php, line 45
Definition of Drupal\ban\EventSubscriber\BanSubscriber.

Class

BanSubscriber
Ban subscriber for controller requests.

Namespace

Drupal\ban\EventSubscriber

Code

public function onKernelRequestBannedIpCheck(GetResponseEvent $event) {

  // @todo convert this to Request::getClientIP().
  $ip = ip_address();
  if ($this->manager
    ->isDenied($ip)) {
    $response = new Response('Sorry, ' . check_plain($ip) . ' has been banned.', 403);
    $event
      ->setResponse($response);
  }
}