-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlockModelsAsset.php
39 lines (33 loc) · 969 Bytes
/
BlockModelsAsset.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
namespace jesuso\blockmodels;
class BlockModelsAsset extends \yii\web\AssetBundle
{
const BM_ASSET = 'BM_ASSET';
public $js = self::BM_ASSET;
public $css = self::BM_ASSET;
public $sourcePath;
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
'yii\jui\JuiAsset',
];
public function init()
{
parent::init();
$this->sourcePath = __DIR__ . '/assets';
$this->setupAssets('css', ['css/blockmodels']);
$this->setupAssets('js', ['js/blockmodels']);
}
protected function setupAssets($type, $files = [])
{
if ($this->$type === self::BM_ASSET) {
$srcFiles = [];
$minFiles = [];
foreach ($files as $file) {
$srcFiles[] = "{$file}.{$type}";
$minFiles[] = "{$file}.min.{$type}";
}
$this->$type = YII_DEBUG ? $srcFiles : $minFiles;
}
}
}