AssetConverter::runCommand()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 4
1
<?php
2
/**
3
 * Pluggable themes for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-thememanager
6
 * @package   yii2-thememanager
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\thememanager;
12
13
use Yii;
14
15
/**
16
 * Asset Converter.
17
 */
18
class AssetConverter extends \yii\web\AssetConverter
19
{
20
    public function init()
21
    {
22
        $this->commands = array_merge([
23
            'php' => ['css', 'render'],
24
        ], $this->commands);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    protected function runCommand($command, $basePath, $asset, $result)
31
    {
32
        if ($command === 'render') {
33
            $res = Yii::$app->getView()->renderFile("$basePath/$asset");
34
            file_put_contents("$basePath/$result", $res);
35
        } else {
36
            return parent::runCommand($command, $basePath, $asset, $result);
37
        }
38
    }
39
}
40