forked from kartik-v/yii2-krajee-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssetBundle.php
62 lines (56 loc) · 1.52 KB
/
AssetBundle.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
/**
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014
* @package yii2-krajee-base
* @version 1.5.0
*/
namespace kartik\base;
/**
* Base asset bundle for all widgets
*
* @author Kartik Visweswaran <[email protected]>
* @since 1.0
*/
class AssetBundle extends \yii\web\AssetBundle
{
const EMPTY_ASSET = 'N0/@$$3T$';
const EMPTY_PATH = 'N0/P@T#';
public $depends = [
'yii\web\JqueryAsset',
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
/**
* 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 = [])
{
if (empty($this->$type)) {
$srcFiles = [];
$minFiles = [];
foreach ($files as $file) {
$srcFiles[] = "{$file}.{$type}";
$minFiles[] = "{$file}.min.{$type}";
}
$this->$type = YII_DEBUG ? $srcFiles : $minFiles;
} elseif ($this->$type === self::EMPTY_ASSET) {
$this->$type = [];
}
}
/**
* 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;
} elseif ($this->sourcePath === self::EMPTY_PATH) {
$this->sourcePath = null;
}
}
}