3 namespace Drupal\form_test\StackMiddleware;
5 use Symfony\Component\HttpFoundation\Request;
6 use Symfony\Component\HttpKernel\HttpKernelInterface;
9 * Provides a test middleware which sets a custom response header.
11 class FormTestMiddleware implements HttpKernelInterface {
14 * The decorated kernel.
16 * @var \Symfony\Component\HttpKernel\HttpKernelInterface
18 protected $httpKernel;
21 * Constructs a FormTestMiddleware object.
23 * @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
24 * The decorated kernel.
26 public function __construct(HttpKernelInterface $http_kernel) {
27 $this->httpKernel = $http_kernel;
33 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) {
34 $response = $this->httpKernel->handle($request, $type, $catch);
35 $response->headers->set('X-Form-Test-Stack-Middleware', 'invoked');