You are here

public function IPRangesEventSubscriber::onKernelRequest in IP Ranges 8

File

lib/Drupal/ip_ranges/EventSubscriber/IPRangesEventSubscriber.php, line 23

Class

IPRangesEventSubscriber

Namespace

Drupal\ip_ranges\EventSubscriber

Code

public function onKernelRequest(GetResponseEvent $event) {
  if ($this->manager
    ->ipIsBanned($this->request
    ->getClientIp())) {
    $event
      ->stopPropagation();
    $response = new Response(t('Sorry, @ip has been banned.', array(
      '@ip' => $this->request
        ->getClientIp(),
    )), 403);
    $event
      ->setResponse($response);
  }
}