FormTestMiddleware.php
Same filename in other branches
Namespace
Drupal\form_test\StackMiddlewareFile
-
core/
modules/ system/ tests/ modules/ form_test/ src/ StackMiddleware/ FormTestMiddleware.php
View source
<?php
namespace Drupal\form_test\StackMiddleware;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
/**
* Provides a test middleware which sets a custom response header.
*/
class FormTestMiddleware implements HttpKernelInterface {
/**
* The decorated kernel.
*
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
*/
protected $httpKernel;
/**
* Constructs a FormTestMiddleware object.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
* The decorated kernel.
*/
public function __construct(HttpKernelInterface $http_kernel) {
$this->httpKernel = $http_kernel;
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE) : Response {
$response = $this->httpKernel
->handle($request, $type, $catch);
$response->headers
->set('X-Form-Test-Stack-Middleware', 'invoked');
return $response;
}
}
Classes
Title | Deprecated | Summary |
---|---|---|
FormTestMiddleware | Provides a test middleware which sets a custom response header. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.