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

BlogOverviewAction   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 14 2
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
}