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

View   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
wmc 6
lcom 2
cbo 2
dl 0
loc 39
ccs 8
cts 12
cp 0.6667
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 1
A getConfig() 0 4 1
A getContext() 0 4 1
A existsTemplate() 0 4 1
A render() 0 4 2
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