annotate vendor/chi-teck/drupal-code-generator/templates/d8/service/middleware.twig @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace Drupal\{{ machine_name }};
Chris@0 4
Chris@0 5 use Drupal\Core\StringTranslation\StringTranslationTrait;
Chris@0 6 use Symfony\Component\HttpFoundation\Request;
Chris@0 7 use Symfony\Component\HttpFoundation\Response;
Chris@0 8 use Symfony\Component\HttpKernel\HttpKernelInterface;
Chris@0 9
Chris@0 10 /**
Chris@0 11 * {{ class }} middleware.
Chris@0 12 */
Chris@0 13 class {{ class }} implements HttpKernelInterface {
Chris@0 14
Chris@0 15 use StringTranslationTrait;
Chris@0 16
Chris@0 17 /**
Chris@0 18 * The kernel.
Chris@0 19 *
Chris@0 20 * @var \Symfony\Component\HttpKernel\HttpKernelInterface
Chris@0 21 */
Chris@0 22 protected $httpKernel;
Chris@0 23
Chris@0 24 /**
Chris@0 25 * Constructs the {{ class }} object.
Chris@0 26 *
Chris@0 27 * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
Chris@0 28 * The decorated kernel.
Chris@0 29 */
Chris@0 30 public function __construct(HttpKernelInterface $http_kernel) {
Chris@0 31 $this->httpKernel = $http_kernel;
Chris@0 32 }
Chris@0 33
Chris@0 34 /**
Chris@0 35 * {@inheritdoc}
Chris@0 36 */
Chris@0 37 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
Chris@0 38
Chris@0 39 if ($request->getClientIp() == '127.0.0.10') {
Chris@0 40 return new Response($this->t('Bye!'), 403);
Chris@0 41 }
Chris@0 42
Chris@0 43 return $this->httpKernel->handle($request, $type, $catch);
Chris@0 44 }
Chris@0 45
Chris@0 46 }