Completed
Push — master ( 3204cd...9afd5c )
by Andrii
02:53
created

View::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1.0787

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 7
cp 0.5714
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 1.0787
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-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\base;
12
13
use Yii;
14
15
/**
16
 * Our View.
17
 */
18
class View extends \yii\base\View
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public $defaultExtension = 'twig';
24
25 5
    public function init()
26
    {
27
        parent::init();
28 5
        $this->theme->pathMap['@app/views'] = array_merge(
29 5
            (array) $this->theme->pathMap['@app/views'],
30
            (array) Yii::$app->get('config')->rawItem('views')
31
        );
32 5
    }
33
34
    public function getConfig()
35
    {
36
        return Yii::$app->config;
37
    }
38
39
    /**
40
     * Returns rendering context.
41
     */
42 3
    public function getContext()
43
    {
44 3
        return Yii::$app;
45
    }
46
47
    public function existsTemplate($template)
48
    {
49
        return file_exists($this->findViewFile($template, $this->getContext()));
50
    }
51
52 3
    public function render($template, $data = [], $context = null)
53
    {
54
        return parent::render($template, $data, isset($context) ? $context : $this->getContext());
55 3
    }
56
}
57