This repository has been archived on 2024-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
yii2-fancytree-widget/FancytreeAsset.php
Wanderson Braganca 77b5bbfed1 PSR 4 alias change
2014-11-09 12:37:40 -02:00

65 lines
1.6 KiB
PHP

<?php
/**
* @link https://github.com/wbraganca/yii2-fancytree-widget
* @copyright Copyright (c) 2014 Wanderson Bragança
* @license https://github.com/wbraganca/yii2-fancytree-widget/blob/master/LICENSE
*/
namespace wbraganca\fancytree;
/**
* Asset bundle for fancytree Widget
*
* @author Wanderson Bragança <wanderson.wbc@gmail.com>
*/
class FancytreeAsset extends \yii\web\AssetBundle
{
/**
* @inheritdoc
*/
public $depends = [
'yii\web\JqueryAsset',
'yii\jui\JuiAsset'
];
/**
* 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('css', ['skin-lion/ui.fancytree']);
$this->setupAssets('js', ['jquery.fancytree']);
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;
}
}
}