Completed
Push — master ( 2d5ed5...57ba8c )
by Daniel
12s
created

Container::loadTwig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Psi\Bridge\ContentType\Twig\Tests\Functional;
4
5
use Psi\Bridge\ContentType\Twig\ContentTypeExtension;
6
use Psi\Bridge\ContentType\Twig\TwigRenderer;
7
use Psi\Component\ContentType\Tests\Functional\Container as BaseContainer;
8
9
class Container extends BaseContainer
10
{
11
    public function __construct(array $config)
12
    {
13
        parent::__construct(array_merge([
14
            'mapping' => [],
15
            'db_path' => __DIR__ . '/../../../../cache/test.sqlite',
16
        ], $config));
17
18
        $this->loadTwig();
19
    }
20
21
    private function loadTwig()
22
    {
23
        $this['psi_content_type.view.twig.renderer'] = function ($container) {
24
            return new TwigRenderer($container['twig']);
25
        };
26
        $this['twig'] = function () {
27
            $twig = new \Twig_Environment(new \Twig_Loader_Filesystem(__DIR__ . '/../../templates'), [
28
                'debug' => true,
29
                'strict_variables' => true,
30
            ]);
31
32
            return $twig;
33
        };
34
35
        $this['twig']->addExtension(new ContentTypeExtension($this['psi_content_type.view.twig.renderer']));
36
    }
37
}
38