forked from stackphp/builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStackedHttpKernel.php
More file actions
34 lines (28 loc) · 970 Bytes
/
Copy pathStackedHttpKernel.php
File metadata and controls
34 lines (28 loc) · 970 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
namespace Stack;
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 $app;
private $middlewares = array();
public function __construct(HttpKernelInterface $app, array $middlewares)
{
$this->app = $app;
$this->middlewares = $middlewares;
}
public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
{
return $this->app->handle($request, $type, $catch);
}
public function terminate(Request $request, Response $response)
{
foreach ($this->middlewares as $kernel) {
if ($kernel instanceof TerminableInterface) {
$kernel->terminate($request, $response);
}
}
}
}