Passed
Pull Request — master (#122)
by Sergei
12:04
created

ApplicationViewInjection::getLayoutParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\ViewRenderer;
6
7
use Yiisoft\Router\UrlMatcherInterface;
8
use Yiisoft\Yii\Web\User\User;
9
10
class ApplicationViewInjection implements
11
    LayoutParamsInjectionInterface,
12
    MetaTagsInjectionInterface,
13
    LinkTagsInjectionInterface
14
{
15
16
    private User $user;
17
    private UrlMatcherInterface $urlMatcher;
18
19
    public function __construct(
20
        User $user,
21
        UrlMatcherInterface $urlMatcher
22
    ) {
23
        $this->user = $user;
24
        $this->urlMatcher = $urlMatcher;
25
    }
26
27
    public function getLayoutParams(): array
28
    {
29
        return [
30
            'user' => $this->user->getIdentity(),
31
            'currentUrl' => (string)$this->urlMatcher->getLastMatchedRequest()->getUri(),
32
            'brandLabel' => 'Yii Demo',
33
        ];
34
    }
35
36
    public function getMetaTags(): array
37
    {
38
        return [
39
            [
40
                '__key' => 'generator',
41
                'name' => 'generator',
42
                'value' => 'Yii',
43
            ],
44
        ];
45
    }
46
47
    public function getLinkTags(): array
48
    {
49
        return [
50
            [
51
                '__key' => 'favicon',
52
                'name' => 'icon',
53
                'value' => 'favicon.ico',
54
            ],
55
        ];
56
    }
57
}
58