forked from kartik-v/yii2-widget-fileinput
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileInputThemeAsset.php
62 lines (55 loc) · 1.38 KB
/
FileInputThemeAsset.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 - 2016
* @package yii2-widgets
* @subpackage yii2-widget-fileinput
* @version 1.0.5
*/
namespace kartik\file;
use kartik\base\AssetBundle;
use Yii;
/**
* Theme Asset bundle for the FileInput Widget
*
* @author Kartik Visweswaran <kartikv2@gmail.com>
* @since 1.0
*/
class FileInputThemeAsset extends AssetBundle
{
/**
* @inheritdoc
*/
public $sourcePath = '@vendor/kartik-v/bootstrap-fileinput';
/**
* @inheritdoc
*/
public $depends = ['kartik\file\FileInputAsset'];
/**
* Add file input theme file
*
* @param string $theme the theme file name
*/
public function addTheme($theme)
{
$file = YII_DEBUG ? "theme.js" : "theme.min.js";
if ($this->checkExists("themes/{$theme}/{$file}")) {
$this->js[] = "themes/{$theme}/{$file}";
}
$file = YII_DEBUG ? "theme.css" : "theme.min.css";
if ($this->checkExists("themes/{$theme}/{$file}")) {
$this->css[] = "themes/{$theme}/{$file}";
}
return $this;
}
/**
* Check if file exists in path provided
*
* @param string $path the file path
*
* @return bool
*/
protected function checkExists($path)
{
return file_exists(Yii::getAlias($this->sourcePath . '/' . $path));
}
}