Browse Source

Fixes #996.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
602592411d
  1. 16
      framework/yii/console/controllers/AssetController.php
  2. 2
      framework/yii/web/AssetBundle.php
  3. 14
      framework/yii/web/AssetManager.php

16
framework/yii/console/controllers/AssetController.php

@ -136,7 +136,6 @@ class AssetController extends Controller
$this->loadConfiguration($configFile);
$bundles = $this->loadBundles($this->bundles);
$targets = $this->loadTargets($this->targets, $bundles);
$this->publishBundles($bundles, $this->assetManager);
$timestamp = time();
foreach ($targets as $name => $target) {
echo "Creating output bundle '{$name}':\n";
@ -276,21 +275,6 @@ class AssetController extends Controller
}
/**
* Publishes given asset bundles.
* @param \yii\web\AssetBundle[] $bundles asset bundles to be published.
*/
protected function publishBundles($bundles)
{
echo "\nPublishing bundles:\n";
$assetManager = $this->getAssetManager();
foreach ($bundles as $name => $bundle) {
$bundle->publish($assetManager);
echo " '".$name."' published.\n";
}
echo "\n";
}
/**
* Builds output asset bundle.
* @param \yii\web\AssetBundle $target output asset bundle
* @param string $type either 'js' or 'css'.

2
framework/yii/web/AssetBundle.php

@ -138,8 +138,6 @@ class AssetBundle extends Object
*/
public function registerAssets($view)
{
$this->publish($view->getAssetManager());
foreach ($this->js as $js) {
$view->registerJsFile($this->baseUrl . '/' . $js, $this->jsOptions);
}

14
framework/yii/web/AssetManager.php

@ -101,15 +101,19 @@ class AssetManager extends Component
public function getBundle($name)
{
if (isset($this->bundles[$name])) {
if (is_array($this->bundles[$name])) {
$this->bundles[$name] = Yii::createObject(array_merge(array('class' => $name), $this->bundles[$name]));
} elseif (!$this->bundles[$name] instanceof AssetBundle) {
if ($this->bundles[$name] instanceof AssetBundle) {
return $this->bundles[$name];
} elseif (is_array($this->bundles[$name])) {
$bundle = Yii::createObject(array_merge(array('class' => $name), $this->bundles[$name]));
} else {
throw new InvalidConfigException("Invalid asset bundle: $name");
}
} else {
$this->bundles[$name] = Yii::createObject($name);
$bundle = Yii::createObject($name);
}
return $this->bundles[$name];
/** @var AssetBundle $bundle */
$bundle->publish($this);
return $this->bundles[$name] = $bundle;
}
private $_converter;

Loading…
Cancel
Save