From 1ec2e7face1252345b03c49ab242d24c76acd241 Mon Sep 17 00:00:00 2001 From: Nicola Petracchi Date: Fri, 26 May 2017 12:18:20 +0200 Subject: [PATCH 1/5] Add unpositioned bundle for CSS if never configured in bundles. --- src/Combiner.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Combiner.php b/src/Combiner.php index 583cddc..c696ea6 100644 --- a/src/Combiner.php +++ b/src/Combiner.php @@ -74,7 +74,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(); } From 777d7402d3a48e0b7110f89d27d56fda178fdec2 Mon Sep 17 00:00:00 2001 From: Nicola Petracchi Date: Thu, 22 Jun 2017 17:23:39 +0200 Subject: [PATCH 2/5] Added the awareness of AssetManager and platform configuration to selective choose compile folders. --- src/Combiner.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/src/Combiner.php b/src/Combiner.php index c696ea6..fae3aad 100644 --- a/src/Combiner.php +++ b/src/Combiner.php @@ -36,6 +36,16 @@ 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. */ @@ -52,8 +62,13 @@ class Combiner extends \yii\base\Object 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); } /** @@ -213,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) { @@ -223,7 +238,6 @@ protected function getAssetBundles($position = null) $this->_assetBundles[$position] = new AssetBundle($config); } - return $this->_assetBundles[$position]; } From 67598b862d52270e36f8a5c67e287484cc3e8452 Mon Sep 17 00:00:00 2001 From: federico biagini Date: Tue, 25 Jul 2017 10:42:25 +0200 Subject: [PATCH 3/5] The visibility of two variables ( and ) of the class Combiner has been changed (from private to protected) to allow easier extension --- src/Combiner.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Combiner.php b/src/Combiner.php index fae3aad..36fa3e7 100644 --- a/src/Combiner.php +++ b/src/Combiner.php @@ -49,12 +49,12 @@ class Combiner extends \yii\base\Object /** * @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 From f99a29be667dc0a1d7df90925c5b8755fc0faee4 Mon Sep 17 00:00:00 2001 From: Nicola Petracchi Date: Thu, 8 Feb 2018 12:08:29 +0100 Subject: [PATCH 4/5] Updating deprecated packages from composer.json --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index dea5633..d19bc57 100644 --- a/composer.json +++ b/composer.json @@ -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": { From 0482e3f8af5c861e2aadbb3910670b0e00f312b6 Mon Sep 17 00:00:00 2001 From: federico biagini Date: Wed, 20 Jun 2018 14:22:28 +0200 Subject: [PATCH 5/5] Code update to make it compatible with php 7.2 --- src/Combiner.php | 2 +- src/Component.php | 2 +- src/Minifier.php | 2 +- src/minifiers/CliMinifier.php | 2 +- src/minifiers/PhpCssMinifier.php | 2 +- src/minifiers/PhpJsMinifier.php | 2 +- src/minifiers/WebMinifier.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Combiner.php b/src/Combiner.php index 36fa3e7..49443a7 100644 --- a/src/Combiner.php +++ b/src/Combiner.php @@ -13,7 +13,7 @@ * @author Lajos Molnár * @since 1.0 */ -class Combiner extends \yii\base\Object +class Combiner extends \yii\base\BaseObject { /** diff --git a/src/Component.php b/src/Component.php index a8758e4..8b5d88d 100644 --- a/src/Component.php +++ b/src/Component.php @@ -23,7 +23,7 @@ * @author Lajos Molnár * @since 1.0 */ -class Component extends \yii\base\Object +class Component extends \yii\base\BaseObject { /** diff --git a/src/Minifier.php b/src/Minifier.php index ab35f2a..db9e281 100644 --- a/src/Minifier.php +++ b/src/Minifier.php @@ -13,7 +13,7 @@ * @author Lajos Molnár * @since 1.0 */ -class Minifier extends \yii\base\Object +class Minifier extends \yii\base\BaseObject { /** diff --git a/src/minifiers/CliMinifier.php b/src/minifiers/CliMinifier.php index 21323ac..00f02d8 100644 --- a/src/minifiers/CliMinifier.php +++ b/src/minifiers/CliMinifier.php @@ -8,7 +8,7 @@ * @author Lajos Molnár * @since 1.0 */ -class CliMinifier extends \yii\base\Object implements MinifierInterface +class CliMinifier extends \yii\base\BaseObject implements MinifierInterface { /** diff --git a/src/minifiers/PhpCssMinifier.php b/src/minifiers/PhpCssMinifier.php index 1befbc9..3543958 100644 --- a/src/minifiers/PhpCssMinifier.php +++ b/src/minifiers/PhpCssMinifier.php @@ -10,7 +10,7 @@ * @author Lajos Molnár * @since 1.0 */ -class PhpCssMinifier extends \yii\base\Object implements MinifierInterface +class PhpCssMinifier extends \yii\base\BaseObject implements MinifierInterface { /** diff --git a/src/minifiers/PhpJsMinifier.php b/src/minifiers/PhpJsMinifier.php index 2427186..f2493ba 100644 --- a/src/minifiers/PhpJsMinifier.php +++ b/src/minifiers/PhpJsMinifier.php @@ -10,7 +10,7 @@ * @author Lajos Molnár * @since 1.0 */ -class PhpJsMinifier extends \yii\base\Object implements MinifierInterface +class PhpJsMinifier extends \yii\base\BaseObject implements MinifierInterface { /** diff --git a/src/minifiers/WebMinifier.php b/src/minifiers/WebMinifier.php index d5fc116..3e01d74 100644 --- a/src/minifiers/WebMinifier.php +++ b/src/minifiers/WebMinifier.php @@ -8,7 +8,7 @@ * @author Lajos Molnár * @since 1.0 */ -class WebMinifier extends \yii\base\Object implements MinifierInterface +class WebMinifier extends \yii\base\BaseObject implements MinifierInterface { /**