@@ 20-39 (lines=20) @@ | ||
17 | /** |
|
18 | * Base for components. |
|
19 | */ |
|
20 | class Component extends \yii\base\Component implements ViewContextInterface |
|
21 | { |
|
22 | use GettersTrait; |
|
23 | ||
24 | public function render($view, $params = []) |
|
25 | { |
|
26 | return Yii::$app->getView()->render($view, array_merge([ |
|
27 | 'app' => Yii::$app, |
|
28 | 'config' => Yii::$app, |
|
29 | 'component' => $this, |
|
30 | ], $params), $this); |
|
31 | } |
|
32 | ||
33 | public function getViewPath() |
|
34 | { |
|
35 | $ref = new ReflectionClass($this); |
|
36 | ||
37 | return dirname(dirname($ref->getFileName())) . '/views'; |
|
38 | } |
|
39 | } |
|
40 |
@@ 22-40 (lines=19) @@ | ||
19 | * |
|
20 | * @property string $minimalPath path to minimal example file |
|
21 | */ |
|
22 | class Module extends \yii\base\Module implements ViewContextInterface |
|
23 | { |
|
24 | use GettersTrait; |
|
25 | ||
26 | public function render($view, $params = []) |
|
27 | { |
|
28 | return Yii::$app->getView()->render($view, array_merge([ |
|
29 | 'module' => $this, |
|
30 | 'config' => Yii::$app->get('config'), |
|
31 | ], $params), $this); |
|
32 | } |
|
33 | ||
34 | public function getViewPath() |
|
35 | { |
|
36 | $ref = new ReflectionClass($this); |
|
37 | ||
38 | return dirname($ref->getFileName()) . '/views'; |
|
39 | } |
|
40 | } |
|
41 |