StackedHttpKernel.php in Drupal 10
File
core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php
View source
<?php
namespace Drupal\Core\StackMiddleware;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class StackedHttpKernel implements HttpKernelInterface, TerminableInterface {
private $kernel;
private $middlewares = [];
public function __construct(HttpKernelInterface $kernel, array $middlewares) {
$this->kernel = $kernel;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = TRUE) : Response {
return $this->kernel
->handle($request, $type, $catch);
}
public function terminate(Request $request, Response $response) {
$previous = NULL;
foreach ($this->middlewares as $kernel) {
if (!$previous instanceof TerminableInterface && $kernel instanceof TerminableInterface) {
$kernel
->terminate($request, $response);
}
$previous = $kernel;
}
}
}