Completed
Pull Request — master (#204)
by
unknown
06:57
created

AdminAsset   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 36
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A init() 0 20 3
1
<?php
2
3
namespace app\modules\backend\assets;
4
5
/*
6
 * @link http://www.yiiframework.com/
7
 *
8
 * @copyright Copyright (c) 2008 Yii Software LLC
9
 * @license http://www.yiiframework.com/license/
10
 */
11
12
use yii\helpers\FileHelper;
13
use yii\web\AssetBundle;
14
15
/**
16
 * Configuration for `backend` client script files.
17
 *
18
 * @since 4.0
19
 */
20
class AdminAsset extends AssetBundle
21
{
22
    public $sourcePath = '@app/modules/backend/assets/web';
23
24
    public $css = [
25
        'less/site.less',
26
    ];
27
    public $js = [
28
    ];
29
    public $depends = [
30
        'yii\web\YiiAsset',
31
        'yii\bootstrap\BootstrapAsset',
32
        'dmstr\web\AdminLteAsset',
33
    ];
34
35
    public function init()
36
    {
37
        parent::init();
38
        // we recompile the less files from 'yii\bootstrap\BootstrapAsset' and include the css in app.css
39
        // therefore we set bundle to false
40
        \Yii::$app->getAssetManager()->bundles['yii\bootstrap\BootstrapAsset'] = false;
41
42
        // /!\ CSS/LESS development only setting /!\
43
        // Touch the asset folder with the highest mtime of all contained files
44
        // This will create a new folder in web/assets for every change and request
45
        // made to the app assets.
46
        if (getenv('APP_ASSET_FORCE_PUBLISH')) {
47
            $files = FileHelper::findFiles(\Yii::getAlias($this->sourcePath));
0 ignored issues
show
Bug introduced by
It seems like \Yii::getAlias($this->sourcePath) targeting yii\BaseYii::getAlias() can also be of type boolean; however, yii\helpers\BaseFileHelper::findFiles() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
48
            $mtimes = [];
49
            foreach ($files as $file) {
50
                $mtimes[] = filemtime($file);
51
            }
52
            touch(\Yii::getAlias($this->sourcePath), max($mtimes));
53
        }
54
    }
55
}
56