1 | <?php |
||
13 | class NextHandlerAdapter implements RequestHandlerInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var Request |
||
17 | */ |
||
18 | private $foundationRequest; |
||
19 | |||
20 | /** |
||
21 | * @var Closure |
||
22 | */ |
||
23 | private $next; |
||
24 | |||
25 | /** |
||
26 | * @var PsrHttpFactory |
||
27 | */ |
||
28 | private $psrHttpFactory; |
||
29 | |||
30 | /** |
||
31 | * @var HttpFoundationFactory |
||
32 | */ |
||
33 | private $httpFoundationFactory; |
||
34 | |||
35 | 2 | public function __construct( |
|
46 | |||
47 | /** |
||
48 | * Intercept communication between the PSR-15 middleware and the next middleware/controller. |
||
49 | * |
||
50 | * To allow the next execution we need to restore the request to a HttpFoundationRequest |
||
51 | * and wait for a response that must be adapter to PSR-7 response to allow the |
||
52 | * PSR-15 middleware process it. |
||
53 | * |
||
54 | * @param ServerRequestInterface $psr7Request |
||
55 | * |
||
56 | * @return ResponseInterface |
||
57 | */ |
||
58 | 2 | public function handle(ServerRequestInterface $psr7Request): ResponseInterface |
|
65 | |||
66 | 2 | private function convertRequest(ServerRequestInterface $psr7Request, $originalRequest): Request |
|
80 | |||
81 | /** |
||
82 | * @param $response |
||
83 | * |
||
84 | * @return ResponseInterface |
||
85 | */ |
||
86 | 2 | protected function getPsr7Response($response): ResponseInterface |
|
90 | } |
||
91 |