Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"yiisoft/yii2": "*",
"natxet/cssmin":"3.*",
"tedivm/jshrink":"1.*",
"packagist/yuicompressor-bin":"*",
"packagist/closurecompiler-bin":"*"
"packagelist/yuicompressor-bin":"*",
"packagelist/closurecompiler-bin":"*"
},
"autoload": {
"psr-4": {
Expand Down
35 changes: 26 additions & 9 deletions src/Combiner.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class Combiner extends \yii\base\Object
class Combiner extends \yii\base\BaseObject
{

/**
Expand All @@ -36,24 +36,39 @@ class Combiner extends \yii\base\Object
*/
public $combinedFilesPath = '/lajax-asset-minifier';

/**
* @var string the Web-accessible directory that contains the asset files in this bundle.
*/
public $basePath;

/**
* @var string the base URL for the relative asset files listed in [[js]] and [[css]].
*/
public $baseUrl;

/**
* @var array List of JavaScript és StyleSheet files grouped by positions.
*/
private $_files = [];
protected $_files = [];

/**
* @var \yii\web\AssetBundle[] List of AssetBundle objects handling combined files.
*/
private $_assetBundles = [];
protected $_assetBundles = [];

/**
* @inheritdoc
*/
public function init()
{
parent::init();

FileHelper::createDirectory(Yii::getAlias('@webroot/assets' . $this->combinedFilesPath), 0777);
if(empty($this->basePath)) {
$this->basePath = \Yii::$app->assetManager->basePath . '/' . $this->combinedFilesPath;
}
if(empty($this->baseUrl)) {
$this->baseUrl = \Yii::$app->assetManager->baseUrl . '/' . $this->combinedFilesPath;
}
FileHelper::createDirectory(Yii::getAlias($this->basePath), 0777);
}

/**
Expand All @@ -74,7 +89,10 @@ public function process()
foreach (array_keys(Yii::$app->view->assetBundles) as $name) {
$this->combineAssetBundles($name);
}

// If empty position is not created, do it now for CSS
if (!isset($this->_assetBundles[''])) {
$this->getAssetBundles();
}
$this->saveAssetFiles();
}

Expand Down Expand Up @@ -210,8 +228,8 @@ protected function getAssetBundles($position = null)
{
if (!isset($this->_assetBundles[$position])) {
$config = [
'basePath' => Yii::getAlias('@webroot/assets' . $this->combinedFilesPath),
'baseUrl' => Yii::getAlias('@web/assets' . $this->combinedFilesPath)
'basePath' => Yii::getAlias($this->basePath),
'baseUrl' => Yii::getAlias($this->baseUrl)
];

if ($position) {
Expand All @@ -220,7 +238,6 @@ protected function getAssetBundles($position = null)

$this->_assetBundles[$position] = new AssetBundle($config);
}

return $this->_assetBundles[$position];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Component.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class Component extends \yii\base\Object
class Component extends \yii\base\BaseObject
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Minifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class Minifier extends \yii\base\Object
class Minifier extends \yii\base\BaseObject
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/minifiers/CliMinifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class CliMinifier extends \yii\base\Object implements MinifierInterface
class CliMinifier extends \yii\base\BaseObject implements MinifierInterface
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/minifiers/PhpCssMinifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class PhpCssMinifier extends \yii\base\Object implements MinifierInterface
class PhpCssMinifier extends \yii\base\BaseObject implements MinifierInterface
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/minifiers/PhpJsMinifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class PhpJsMinifier extends \yii\base\Object implements MinifierInterface
class PhpJsMinifier extends \yii\base\BaseObject implements MinifierInterface
{

/**
Expand Down
2 changes: 1 addition & 1 deletion src/minifiers/WebMinifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @author Lajos Molnár <lajax.m@gmail.com>
* @since 1.0
*/
class WebMinifier extends \yii\base\Object implements MinifierInterface
class WebMinifier extends \yii\base\BaseObject implements MinifierInterface
{

/**
Expand Down