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\handlers; |
||
12 | |||
13 | use Yii; |
||
14 | |||
15 | /** |
||
16 | * Handler for templated files. |
||
17 | */ |
||
18 | class TemplateHandler extends BaseHandler |
||
19 | { |
||
20 | /** |
||
21 | * {@inheritdoc} |
||
22 | */ |
||
23 | public function renderPrepared(array $data) |
||
24 | { |
||
25 | return $this->getView()->render($this->template, $data); |
||
26 | } |
||
27 | |||
28 | public function renderTemplate($data) |
||
29 | { |
||
30 | return $this->renderPrepared(self::prepareData($data)); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
![]() |
|||
31 | } |
||
32 | |||
33 | public function prepareData($data) |
||
34 | { |
||
35 | return array_merge([ |
||
36 | 'app' => Yii::$app, |
||
37 | 'config' => Yii::$app, /// DEPRECATED |
||
38 | 'file' => $data->file, |
||
39 | 'handler' => $this, |
||
40 | ], parent::prepareData($data)); |
||
41 | } |
||
42 | |||
43 | 3 | public function existsTemplate() |
|
44 | { |
||
45 | 3 | return $this->template && $this->getView()->existsTemplate($this->template); |
|
46 | } |
||
47 | } |
||
48 |