Conditions | 4 |
Paths | 6 |
Total Lines | 14 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | public function __invoke(ServerRequestInterface $request, array $args): ResponseInterface |
||
36 | { |
||
37 | $name = isset($args['name']) ? $args['name'] : 'index'; |
||
38 | if (!$document = $this->source->find($name)) { |
||
|
|||
39 | throw new NotFoundException('Page not found'); |
||
40 | } |
||
41 | $data = $document->getFields(); |
||
42 | $data['content'] = $document->getContent(); |
||
43 | $layout = isset($data['layout']) ? $data['layout'] . '.html' : 'default.html'; |
||
44 | $response = $this->response->withAddedHeader( |
||
45 | 'Last-Modified', |
||
46 | $document->getUpdatedAt()->format('D, d M Y H:i:s') . ' GMT' |
||
47 | ); |
||
48 | return $this->view->render($response, $layout, $data); |
||
49 | } |
||
51 |