class StackedHttpKernel
Provides a stacked HTTP kernel.
Copied from https://github.com/stackphp/builder/ with added compatibility for Symfony 6.
Hierarchy
- class \Drupal\Core\StackMiddleware\StackedHttpKernel implements \Symfony\Component\HttpKernel\HttpKernelInterface, \Symfony\Component\HttpKernel\TerminableInterface
Expanded class hierarchy of StackedHttpKernel
See also
\Drupal\Core\DependencyInjection\Compiler\StackedKernelPass
3 files declare their use of StackedHttpKernel
- StackedHttpKernelTest.php in core/
tests/ Drupal/ Tests/ Core/ StackMiddleware/ StackedHttpKernelTest.php - StackedKernelPass.php in core/
lib/ Drupal/ Core/ DependencyInjection/ Compiler/ StackedKernelPass.php - StackedKernelPassTest.php in core/
tests/ Drupal/ Tests/ Core/ DependencyInjection/ Compiler/ StackedKernelPassTest.php
1 string reference to 'StackedHttpKernel'
- core.services.yml in core/
core.services.yml - core/core.services.yml
1 service uses StackedHttpKernel
File
-
core/
lib/ Drupal/ Core/ StackMiddleware/ StackedHttpKernel.php, line 18
Namespace
Drupal\Core\StackMiddlewareView source
class StackedHttpKernel implements HttpKernelInterface, TerminableInterface {
/**
* The decorated kernel.
*
* @var \Symfony\Component\HttpKernel\HttpKernelInterface
*/
private $httpKernel;
/**
* A set of middlewares that are wrapped around this kernel.
*
* @var iterable<\Symfony\Component\HttpKernel\HttpKernelInterface>
*/
private $middlewares = [];
/**
* Constructs a stacked HTTP kernel.
*
* @param \Symfony\Component\HttpKernel\HttpKernelInterface $http_kernel
* The decorated kernel.
* @param iterable<\Symfony\Component\HttpKernel\HttpKernelInterface> $middlewares
* An array of previous middleware services.
*/
public function __construct(HttpKernelInterface $http_kernel, iterable $middlewares) {
if (is_array($middlewares)) {
@trigger_error('Calling ' . __METHOD__ . '() with an array of $middlewares is deprecated in drupal:11.3.0 and it will throw an error in drupal:12.0.0. Pass in a lazy iterator instead. See https://www.drupal.org/node/3538740', E_USER_DEPRECATED);
}
$this->httpKernel = $http_kernel;
$this->middlewares = $middlewares;
}
/**
* {@inheritdoc}
*/
public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = TRUE) : Response {
return $this->httpKernel
->handle($request, $type, $catch);
}
/**
* {@inheritdoc}
*/
public function terminate(Request $request, Response $response) : void {
$previous = NULL;
foreach ($this->middlewares as $kernel) {
// If the previous kernel was terminable we can assume this middleware
// has already been called.
if (!$previous instanceof TerminableInterface && $kernel instanceof TerminableInterface) {
$kernel->terminate($request, $response);
}
$previous = $kernel;
}
}
}
Members
| Title Sort descending | Modifiers | Object type | Summary |
|---|---|---|---|
| StackedHttpKernel::$httpKernel | private | property | The decorated kernel. |
| StackedHttpKernel::$middlewares | private | property | A set of middlewares that are wrapped around this kernel. |
| StackedHttpKernel::handle | public | function | |
| StackedHttpKernel::terminate | public | function | |
| StackedHttpKernel::__construct | public | function | Constructs a stacked HTTP kernel. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.