summaryrefslogtreecommitdiffstats
path: root/src/Controller/View/Twig.php
blob: d232f3430acefb3120ad0687f0acdfd9ff1a4c5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php

namespace Jasny\Controller\View;

use Jasny\Controller\View;
use Jasny\View\Twig as TwigView;

/**
 * View using Twig
 */
trait Twig
{
    use View;
    
    /**
     * Get the template engine abstraction
     * 
     * @return TwigView
     */
    public function getViewer()
    {
        if (!isset($this->viewer)) {
            $this->viewer = $this->createTwigView(['path' => $this->getViewPath()]);
            $this->viewer->addDefaultExtensions();
        }
        
        return $this->viewer;
    }
    
    /**
     * Create a twig view object.
     * @ignore
     * @codeCoverageIgnore
     * 
     * @return TwigView
     */
    protected function createTwigView($options)
    {
        return new TwigView($options);
    }
}