| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 33 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
| 34 | { |
||
| 35 | // Let's only deal with GET requests. |
||
| 36 | if ($request->getMethod() !== 'GET') { |
||
| 37 | return $handler->handle($request); |
||
| 38 | } |
||
| 39 | |||
| 40 | $page = $this->pageRegistry->getPage($request); |
||
| 41 | |||
| 42 | if ($page === null) { |
||
| 43 | return $handler->handle($request); |
||
| 44 | } |
||
| 45 | |||
| 46 | $stream = $this->blockRenderer->renderBlock($page); |
||
| 47 | |||
| 48 | $response = new Response($stream); |
||
| 49 | |||
| 50 | if ($page instanceof CacheableBlock) { |
||
| 51 | $response = $response->withHeader('Expires', gmdate('D, d M Y H:i:s T', time() + $page->getTtl())); |
||
| 52 | } |
||
| 53 | |||
| 54 | return $response; |
||
| 55 | } |
||
| 57 |