Passed
Push — master ( e34aef...380f9e )
by Gabor
09:54
created

PostViewAction::getTemplateData()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 35
Code Lines 24

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 8.8571
c 0
b 0
f 0
cc 2
eloc 24
nc 2
nop 0
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 7.1
6
 *
7
 * @copyright 2012 - 2017 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
declare(strict_types = 1);
13
14
namespace WebHemi\Middleware\Action\Website;
15
16
use WebHemi\Http\ServerRequestInterface;
17
use WebHemi\Middleware\Action\AbstractMiddlewareAction;
18
19
/**
20
 * Class PostViewAction
21
 */
22
class PostViewAction extends AbstractMiddlewareAction
23
{
24
    /**
25
     * Gets template map name or template file path.
26
     *
27
     * @return string
28
     */
29
    public function getTemplateName() : string
30
    {
31
        return 'website-post-view';
32
    }
33
34
    /**
35
     * Gets template data.
36
     *
37
     * @return array
38
     */
39
    public function getTemplateData() : array
40
    {
41
        $routingParams = $this->request->getAttribute(ServerRequestInterface::REQUEST_ATTR_ROUTING_PARAMETERS);
42
43
        $content = 'Lorem ipsum dolor sit amet...';
44
        $testFile = __DIR__.'/../../../../../data/temp/markdownTest.md';
45
46
        if (file_exists($testFile)) {
47
            $content = file_get_contents(__DIR__.'/../../../../../data/temp/markdownTest.md');
48
        }
49
50
        return [
51
            'activeMenu' => '',
52
            'categories' => [
53
                ['url' => 'posts',      'title' => 'Posts',        'icon' => 'chrome_reader_mode',      'new' => 1],
54
                ['url' => 'useful',     'title' => 'Useful infos', 'icon' => 'perm_device_information', 'new' => 0],
55
                ['url' => 'events',     'title' => 'Events',       'icon' => 'event_note',              'new' => 0],
56
                ['url' => 'something',  'title' => 'Something',    'icon' => null,                      'new' => 8],
57
            ],
58
            'tags' => [
59
                ['url' => 'php',    'title' => 'PHP',    'total' => 132, 'new' =>  1],
60
                ['url' => 'coding', 'title' => 'Coding', 'total' => 132, 'new' =>  0],
61
                ['url' => 'munich', 'title' => 'Munich', 'total' => 132, 'new' => 85]
62
            ],
63
            'blogPost' => [
64
                'title'       => 'Fake test',
65
                'publishedAt' => time(),
66
                'author'      => [
67
                    'name' => 'Some User'
68
                ],
69
                'content'     => $content,
70
                'parameter'   => $routingParams
71
            ]
72
        ];
73
    }
74
}
75