/**
* Publishes the asset bundle if its source code is not under Web-accessible directory.
* It will also try to convert non-CSS or JS files (e.g. LESS, Sass) into the corresponding
* CSS or JS files using [[AssetManager::converter|asset converter]].
* @param \yii\web\AssetManager $am the asset manager to perform the asset publishing
*/
public function publish($am)
{
if ($this->sourcePath !== null && !isset($this->basePath, $this->baseUrl)) {
list($this->basePath, $this->baseUrl) = $am->publish($this->sourcePath, $this->publishOptions);
}
$converter = $am->getConverter();
foreach ($this->js as $i => $value) {
if (is_array($value)) {
if (isset($value['file'])) {
$js = $value['file'];
} else {
continue;
}
} else {
$js = $value;
}
if (strpos($js, '/') !== 0 && strpos($js, '://') === false) {
if (isset($this->basePath, $this->baseUrl)) {
$js = $converter->convert($js, $this->basePath);
} else {
$js = '/' . $js;
}
if (is_array($value)) {
$value['file'] = $js;
} else {
$value = $js;
}
$this->js[$i] = $value;
}
}
foreach ($this->css as $i => $value) {
if (is_array($value)) {
if (isset($value['file'])) {
$css = $value['file'];
} else {
continue;
}
} else {
$css = $value;
}
if (strpos($css, '/') !== 0 && strpos($css, '://') === false) {
if (isset($this->basePath, $this->baseUrl)) {
$css = $converter->convert($css, $this->basePath);
} else {
$css = '/' . $css;
}
if (is_array($value)) {
$value['file'] = $css;
} else {
$value = $css;
}
$this->css[$i] = $value;
}
}
}