Commit 60259241 by Qiang Xue

Fixes #996.

parent 86ceee52
......@@ -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'.
......
......@@ -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);
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment