Browse Source

Modified the IAssetConvert interface.

tags/2.0.0-beta
Qiang Xue 12 years ago
parent
commit
241b6fc49a
  1. 4
      yii/web/AssetBundle.php
  2. 11
      yii/web/AssetConverter.php
  3. 6
      yii/web/IAssetConverter.php

4
yii/web/AssetBundle.php

@ -135,10 +135,10 @@ class AssetBundle extends Object
$this->publish($view->getAssetManager()); $this->publish($view->getAssetManager());
foreach ($this->js as $js) { foreach ($this->js as $js) {
$view->registerJsFile($js, $this->jsOptions); $view->registerJsFile($this->baseUrl . '/' . $js, $this->jsOptions);
} }
foreach ($this->css as $css) { foreach ($this->css as $css) {
$view->registerCssFile($css, $this->cssOptions); $view->registerCssFile($this->baseUrl . '/' . $css, $this->cssOptions);
} }
} }

11
yii/web/AssetConverter.php

@ -34,13 +34,12 @@ class AssetConverter extends Component implements IAssetConverter
* Converts a given asset file into a CSS or JS file. * Converts a given asset file into a CSS or JS file.
* @param string $asset the asset file path, relative to $basePath * @param string $asset the asset file path, relative to $basePath
* @param string $basePath the directory the $asset is relative to. * @param string $basePath the directory the $asset is relative to.
* @param string $baseUrl the URL corresponding to $basePath * @return string the converted asset file path, relative to $basePath.
* @return string the URL to the converted asset file.
*/ */
public function convert($asset, $basePath, $baseUrl) public function convert($asset, $basePath)
{ {
$pos = strrpos($asset, '.'); $pos = strrpos($asset, '.');
if ($pos !== false) { if ($pos === false) {
$ext = substr($asset, $pos + 1); $ext = substr($asset, $pos + 1);
if (isset($this->commands[$ext])) { if (isset($this->commands[$ext])) {
list ($ext, $command) = $this->commands[$ext]; list ($ext, $command) = $this->commands[$ext];
@ -54,9 +53,9 @@ class AssetConverter extends Component implements IAssetConverter
exec($command, $output); exec($command, $output);
Yii::info("Converted $asset into $result: " . implode("\n", $output), __METHOD__); Yii::info("Converted $asset into $result: " . implode("\n", $output), __METHOD__);
} }
return "$baseUrl/$result"; return $result;
} }
} }
return "$baseUrl/$asset"; return $asset;
} }
} }

6
yii/web/IAssetConverter.php

@ -19,9 +19,7 @@ interface IAssetConverter
* Converts a given asset file into a CSS or JS file. * Converts a given asset file into a CSS or JS file.
* @param string $asset the asset file path, relative to $basePath * @param string $asset the asset file path, relative to $basePath
* @param string $basePath the directory the $asset is relative to. * @param string $basePath the directory the $asset is relative to.
* @param string $baseUrl the URL corresponding to $basePath * @return string the converted asset file path, relative to $basePath.
* @return string the URL to the converted asset file. If the given asset does not
* need conversion, "$baseUrl/$asset" should be returned.
*/ */
public function convert($asset, $basePath, $baseUrl); public function convert($asset, $basePath);
} }

Loading…
Cancel
Save