From 82de6ed2b016b2762b32b5eeb06c1ea99b72a144 Mon Sep 17 00:00:00 2001 From: Tobias Munk Date: Thu, 10 Oct 2013 05:35:03 +0200 Subject: [PATCH 1/3] added asset file mapping parameter to define files which are remapped after package compression --- PackageCompressor.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/PackageCompressor.php b/PackageCompressor.php index ff1ed61..8e3df8e 100644 --- a/PackageCompressor.php +++ b/PackageCompressor.php @@ -19,6 +19,14 @@ class PackageCompressor extends CClientScript */ public $combineOnly = false; + /** + * @var asset-files mapping + * Files defined in this array (same format as $scriptMap) are NOT remapped before package compression. + * You can use this parameter to override the client-script registration of files which are published as an asset, + * but also defined in a package. Example: Files set to false are included in packages, but not stand-alone. + */ + public $assetsScriptMap = array(); + /** * If this is enabled, during compression all other requests will wait until the compressing * process has completed. If disabled, the uncompressed files will be delivered for these @@ -225,6 +233,10 @@ public function render(&$output) $this->renderCoreScripts(); + // merge scripts from assetsScriptMap, if compression is enabled, since the files have been bundles into packages + if ($this->enableCompression) { + $this->scriptMap = CMap::mergeArray($this->scriptMap, $this->assetsScriptMap); + } if(!empty($this->scriptMap)) $this->remapScripts(); From 775b6950f09770d461d57c75a92a7dd500d1ef7b Mon Sep 17 00:00:00 2001 From: Tobias Munk Date: Sun, 13 Oct 2013 22:57:38 +0200 Subject: [PATCH 2/3] updated property name and handling --- PackageCompressor.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/PackageCompressor.php b/PackageCompressor.php index 8e3df8e..a7a360f 100644 --- a/PackageCompressor.php +++ b/PackageCompressor.php @@ -24,8 +24,15 @@ class PackageCompressor extends CClientScript * Files defined in this array (same format as $scriptMap) are NOT remapped before package compression. * You can use this parameter to override the client-script registration of files which are published as an asset, * but also defined in a package. Example: Files set to false are included in packages, but not stand-alone. + /** + * Files defined in this array ('foo.js','bar.js') are available for package compression but not registered as a + * stand-alone file. + * You can use this parameter for example to override the client-script registration of files which are already + * published as an asset. + * + * @var blocked script files for clientscript registration */ - public $assetsScriptMap = array(); + public $blockedScripts = array(); /** * If this is enabled, during compression all other requests will wait until the compressing @@ -234,8 +241,10 @@ public function render(&$output) $this->renderCoreScripts(); // merge scripts from assetsScriptMap, if compression is enabled, since the files have been bundles into packages - if ($this->enableCompression) { - $this->scriptMap = CMap::mergeArray($this->scriptMap, $this->assetsScriptMap); + if ($this->enableCompression && $this->blockedScripts!==array()) { + foreach($this->blockedScripts AS $script) { + $this->scriptMap[$script] = false; + } } if(!empty($this->scriptMap)) $this->remapScripts(); From 781796ae0f5175869c9fd4081330d62d8cae5272 Mon Sep 17 00:00:00 2001 From: Tobias Munk Date: Wed, 23 Oct 2013 21:03:22 +0200 Subject: [PATCH 3/3] fixed comments --- PackageCompressor.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/PackageCompressor.php b/PackageCompressor.php index a7a360f..db3722f 100644 --- a/PackageCompressor.php +++ b/PackageCompressor.php @@ -19,11 +19,6 @@ class PackageCompressor extends CClientScript */ public $combineOnly = false; - /** - * @var asset-files mapping - * Files defined in this array (same format as $scriptMap) are NOT remapped before package compression. - * You can use this parameter to override the client-script registration of files which are published as an asset, - * but also defined in a package. Example: Files set to false are included in packages, but not stand-alone. /** * Files defined in this array ('foo.js','bar.js') are available for package compression but not registered as a * stand-alone file. @@ -240,7 +235,8 @@ public function render(&$output) $this->renderCoreScripts(); - // merge scripts from assetsScriptMap, if compression is enabled, since the files have been bundles into packages + // Merge scripts from `blockedScripts` if compression is enabled, + // since it is assumed the files have been bundled into packages or handled elsewhere. if ($this->enableCompression && $this->blockedScripts!==array()) { foreach($this->blockedScripts AS $script) { $this->scriptMap[$script] = false;