Completed
Push — master ( 77f861...3204cd )
by Andrii
05:27 queued 01:24
created

View::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 1
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 5
        parent::init();
28 5
        $this->theme->pathMap['@app/views'] = array_merge(
29 5
            (array) $this->theme->pathMap['@app/views'],
30 5
            (array) Yii::$app->get('config')->rawItem('views')
31 5
        );
32 5
    }
33
34
    public function getConfig()
35
    {
36
        return Yii::$app->config;
37
    }
38
39
    /**
40
     * Returns rendering context.
41
     */
42 5
    public function getContext()
43
    {
44 5
        return Yii::$app;
45
    }
46
47
    public function existsTemplate($template)
48
    {
49
        return file_exists($this->findViewFile($template, $this->getContext()));
50
    }
51
52 5
    public function render($template, $data = [], $context = null)
53
    {
54 5
        return parent::render($template, $data, isset($context) ? $context : $this->getContext());
55
    }
56
}
57