View::getContext()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\components;
12
13
use yii\base\ViewContextInterface;
14
15
/**
16
 * Our View.
17
 */
18
class View extends \yii\base\View implements ViewContextInterface
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public $defaultExtension = 'twig';
24
25
    protected $_viewPath;
26
27
    public function getViewPath()
28
    {
29
        if ($this->_viewPath === null) {
30
            $this->_viewPath = '@hidev/views';
31
        }
32
33
        return $this->_viewPath;
34
    }
35
36
    /**
37
     * Returns rendering context.
38
     */
39
    public function getContext($context = null)
40
    {
41
        return $context ?: $this;
42
    }
43
44
    public function existsTemplate($template, $context = null)
45
    {
46
        return file_exists($this->findViewFile($template, $this->getContext($context)));
47
    }
48
49
    public function render($template, $data = [], $context = null)
50
    {
51
        return parent::render($template, $data, $this->getContext($context));
52
    }
53
}
54