mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-30 22:48:19 +08:00
scripts WIP
This commit is contained in:
@@ -98,7 +98,7 @@ class ViewContent extends Component
|
||||
$bundle = $this->assetManager->getBundle($name);
|
||||
if ($bundle !== null) {
|
||||
$this->assetBundles[$name] = false;
|
||||
$bundle->registerWith($this);
|
||||
$bundle->registerAssets($this);
|
||||
$this->assetBundles[$name] = true;
|
||||
} else {
|
||||
throw new InvalidConfigException("Unknown asset bundle: $name");
|
||||
|
||||
@@ -42,10 +42,18 @@ class AssetBundle extends Object
|
||||
public $css = array();
|
||||
public $depends = array();
|
||||
|
||||
public function mapTo($target)
|
||||
{
|
||||
$this->depends = array($target);
|
||||
$this->js = $this->css = array();
|
||||
$this->basePath = null;
|
||||
$this->baseUrl = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \yii\base\ViewContent $content
|
||||
*/
|
||||
public function registerWith($content)
|
||||
public function registerAssets($content)
|
||||
{
|
||||
foreach ($this->depends as $name) {
|
||||
$content->registerAssetBundle($name);
|
||||
@@ -65,4 +73,14 @@ class AssetBundle extends Object
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \yii\web\AssetManager $assetManager
|
||||
*/
|
||||
public function publish($assetManager)
|
||||
{
|
||||
if ($this->basePath !== null && $this->baseUrl === null) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -129,9 +129,23 @@ class AssetManager extends Component
|
||||
$this->bundles[$name] = Yii::createObject($config);
|
||||
}
|
||||
}
|
||||
/** @var $bundle AssetBundle */
|
||||
$bundle = $this->bundles[$name];
|
||||
if (isset($this->bundleMap[$name]) && is_string($this->bundleMap[$name])) {
|
||||
$target = $this->bundleMap[$name];
|
||||
if (!isset($this->bundles[$target])) {
|
||||
if (isset($this->bundleMap[$target])) {
|
||||
$this->bundles[$target] = $this->bundleMap[$target];
|
||||
} else {
|
||||
throw new InvalidConfigException("Asset bundle '$name' is mapped to an unknown bundle: $target");
|
||||
}
|
||||
}
|
||||
$bundle->mapTo($target);
|
||||
unset($this->bundleMap[$name]);
|
||||
}
|
||||
|
||||
if ($publish) {
|
||||
|
||||
$bundle->publish($this);
|
||||
}
|
||||
|
||||
return $this->bundles[$name];
|
||||
|
||||
Reference in New Issue
Block a user