TwigView::initializeExtensions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * BEdita, API-first content management framework
6
 * Copyright 2018 ChannelWeb Srl, Chialab Srl
7
 *
8
 * This file is part of BEdita: you can redistribute it and/or modify
9
 * it under the terms of the GNU Lesser General Public License as published
10
 * by the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
14
 */
15
namespace BEdita\WebTools\View;
16
17
use BEdita\WebTools\View\Twig\BeditaTwigExtension;
18
use Cake\Core\Configure;
19
use Cake\TwigView\View\TwigView as BaseTwigView;
20
21
/**
22
 * View class that uses TwigView and adds Twig extensions
23
 */
24
class TwigView extends BaseTwigView
25
{
26
    /**
27
     * @inheritDoc
28
     */
29
    public function initialize(): void
30
    {
31
        $environment = (array)Configure::read('Twig.environment', []) + ['strict_variables' => false];
32
        $this->setConfig('environment', $environment);
33
34
        parent::initialize();
35
    }
36
37
    /**
38
     * {@inheritDoc}
39
     *
40
     * @codeCoverageIgnore
41
     */
42
    public function initializeExtensions(): void
43
    {
44
        parent::initializeExtensions();
45
        $this->getTwig()->addExtension(new BeditaTwigExtension());
46
    }
47
}
48