forked from maksyutin/yii2-dual-list-box
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Asset.php
62 lines (54 loc) · 1.31 KB
/
Asset.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace maksyutin\duallistbox;
use yii\web\AssetBundle;
/**
* Asset bundle for yii2-dual-list-box Widget
*
* @author Maksyutin Dmitriy <[email protected]>
* @since 1.0
*/
class Asset extends AssetBundle
{
/**
* @inheritdoc
*/
public $depends = [
'yii\web\JqueryAsset',
];
/**
* Set up CSS and JS asset arrays based on the base-file names
* @param string $type whether 'css' or 'js'
* @param array $files the list of 'css' or 'js' basefile names
*/
protected function setupAssets($type, $files = [])
{
$srcFiles = [];
$minFiles = [];
foreach ($files as $file) {
$srcFiles[] = "{$file}.{$type}";
$minFiles[] = "{$file}.min.{$type}";
}
if (empty($this->$type)) {
$this->$type = YII_DEBUG ? $srcFiles : $minFiles;
}
}
/**
* @inheritdoc
*/
public function init()
{
$this->setSourcePath(__DIR__ . '/assets');
$this->setupAssets('js', ['js/dual-list-box']);
parent::init();
}
/**
* Sets the source path if empty
* @param string $path the path to be set
*/
protected function setSourcePath($path)
{
if (empty($this->sourcePath)) {
$this->sourcePath = $path;
}
}
}