Completed
Push — master ( 55fdf1...0c48af )
by Johannes
02:35
created

BlogOverviewAction::getMarkdownDocumentParser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Lichtenwallner  (https://lichtenwallner.at)
4
 *
5
 * @see https://github.com/jolicht/markdown-cms for the canonical source repository
6
 * @license https://github.com/jolicht/markdown-cms/blob/master/LICENSE MIT
7
 * @copyright Copyright (c) Johannes Lichtenwallner
8
 */
9
declare(strict_types = 1);
10
namespace Jolicht\MarkdownCms\Action;
11
12
use Psr\Http\Message\ServerRequestInterface;
13
use Psr\Http\Message\ResponseInterface;
14
use Zend\Diactoros\Response\HtmlResponse;
15
16
class BlogOverviewAction extends AbstractAction
17
{
18
    /**
19
     * Render blog ovierview
20
     *
21
     * {@inheritDoc}
22
     * @see \Jolicht\MarkdownCms\Action\AbstractAction::__invoke()
23
     */
24
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null)
25
    {
26
        $markdownCmsConfig = $this->getMarkdownCmsConfig();
27
        $config = $markdownCmsConfig['content']['content_types']['blogEntry']['all'];
28
        $entries = [];
29
30
        $entryParser = $this->getEntryParser();
31
32
        foreach ($config as $id) {
33
            $entries[] = $entryParser($id);
34
        }
35
36
        return new HtmlResponse($this->getTemplateRenderer()->render('app::blog-overwiew.twig', ['entries' => $entries]));
37
    }
38
}