comparison core/modules/ban/src/BanMiddleware.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 2
3 namespace Drupal\ban; 3 namespace Drupal\ban;
4 4
5 use Drupal\Component\Utility\SafeMarkup; 5 use Drupal\Component\Render\FormattableMarkup;
6 use Symfony\Component\HttpFoundation\Request; 6 use Symfony\Component\HttpFoundation\Request;
7 use Symfony\Component\HttpFoundation\Response; 7 use Symfony\Component\HttpFoundation\Response;
8 use Symfony\Component\HttpKernel\HttpKernelInterface; 8 use Symfony\Component\HttpKernel\HttpKernelInterface;
9 9
10 /** 10 /**
43 * {@inheritdoc} 43 * {@inheritdoc}
44 */ 44 */
45 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) { 45 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
46 $ip = $request->getClientIp(); 46 $ip = $request->getClientIp();
47 if ($this->banIpManager->isBanned($ip)) { 47 if ($this->banIpManager->isBanned($ip)) {
48 return new Response(SafeMarkup::format('@ip has been banned', ['@ip' => $ip]), 403); 48 return new Response(new FormattableMarkup('@ip has been banned', ['@ip' => $ip]), 403);
49 } 49 }
50 return $this->httpKernel->handle($request, $type, $catch); 50 return $this->httpKernel->handle($request, $type, $catch);
51 } 51 }
52 52
53 } 53 }