Mercurial > hg > cmmr2012-drupal-site
comparison vendor/chi-teck/drupal-code-generator/templates/d8/service/middleware.twig @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:c75dbcec494b |
---|---|
1 <?php | |
2 | |
3 namespace Drupal\{{ machine_name }}; | |
4 | |
5 use Drupal\Core\StringTranslation\StringTranslationTrait; | |
6 use Symfony\Component\HttpFoundation\Request; | |
7 use Symfony\Component\HttpFoundation\Response; | |
8 use Symfony\Component\HttpKernel\HttpKernelInterface; | |
9 | |
10 /** | |
11 * {{ class }} middleware. | |
12 */ | |
13 class {{ class }} implements HttpKernelInterface { | |
14 | |
15 use StringTranslationTrait; | |
16 | |
17 /** | |
18 * The kernel. | |
19 * | |
20 * @var \Symfony\Component\HttpKernel\HttpKernelInterface | |
21 */ | |
22 protected $httpKernel; | |
23 | |
24 /** | |
25 * Constructs the {{ class }} object. | |
26 * | |
27 * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel | |
28 * The decorated kernel. | |
29 */ | |
30 public function __construct(HttpKernelInterface $http_kernel) { | |
31 $this->httpKernel = $http_kernel; | |
32 } | |
33 | |
34 /** | |
35 * {@inheritdoc} | |
36 */ | |
37 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) { | |
38 | |
39 if ($request->getClientIp() == '127.0.0.10') { | |
40 return new Response($this->t('Bye!'), 403); | |
41 } | |
42 | |
43 return $this->httpKernel->handle($request, $type, $catch); | |
44 } | |
45 | |
46 } |