kernel = $kernel; $this->middlewares = $middlewares; } /** * {@inheritdoc} */ public function handle(Request $request, $type = HttpKernelInterface::MAIN_REQUEST, $catch = true): Response { return $this->kernel ->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; } } }