Skip to content
Open
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
17 changes: 17 additions & 0 deletions PackageCompressor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ class PackageCompressor extends CClientScript
*/
public $combineOnly = false;

/**
* 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.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, we should update this docs once again, to be 100% precise. What about this (and please correct me if I'm wrong):

When compression is enabled, scripts defined in this array will be ignored if registered 
through `CClientScript::registerScriptFile()`. This way you can package assets from
widgets that don't use the package system. For the time being this is for example the
case for CListView. So you could use:

    'blockedScripts' => array(
        'jquery.yiilistview.js',
    ),
    'packages' => array(
        'listview' => array(
            'basePath' => 'zii.widgets.assets.listview',
            'js' => array('jquery.yiilistview.js'),
        ),
        'mypackage' => array(
           'js' => array( ... ),
           'depends' => array(
               'listview',
           ),
        ),
    ),

*
* @var blocked script files for clientscript registration
*/
public $blockedScripts = 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
Expand Down Expand Up @@ -225,6 +235,13 @@ public function render(&$output)

$this->renderCoreScripts();

// 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;
}
}
if(!empty($this->scriptMap))
$this->remapScripts();

Expand Down