Completed
Push — master ( 2977a7...5955f6 )
by Andrii
03:40
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
/*
4
 * Automation tool mixed with code generator for easier continuous development
5
 *
6
 * @link      https://github.com/hiqdev/hidev
7
 * @package   hidev
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\base;
13
14
use Yii;
15
16
/**
17
 * Our View.
18
 */
19
class View extends \yii\base\View
20
{
21
    /**
22
     * {@inheritdoc}
23
     */
24
    public $defaultExtension = 'twig';
25
26 5
    public function init()
27
    {
28
        parent::init();
29 5
        $this->theme->pathMap['@app/views'] = array_merge(
30 5
            (array) $this->theme->pathMap['@app/views'],
31
            (array) Yii::$app->get('config')->rawItem('views')
32
        );
33 5
    }
34
35
    public function getConfig()
36
    {
37
        return Yii::$app->config;
38
    }
39
40
    /**
41
     * Returns rendering context.
42
     */
43 3
    public function getContext()
44
    {
45 3
        return Yii::$app;
46
    }
47
48
    public function existsTemplate($template)
49
    {
50
        return file_exists($this->findViewFile($template, $this->getContext()));
51
    }
52
53 3
    public function render($template, $data = [], $context = null)
54
    {
55
        return parent::render($template, $data, isset($context) ? $context : $this->getContext());
56 3
    }
57
}
58