Skip to content

Instantly share code, notes, and snippets.

@petrabarus
Created September 13, 2012 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save petrabarus/3711430 to your computer and use it in GitHub Desktop.
Save petrabarus/3711430 to your computer and use it in GitHub Desktop.
<?php
abstract class CAssetWidget extends CWidget {
private static $_assetPaths;
/**
* @param boolean $checkTheme
* @return string
*/
public function getAssetPath($checkTheme) {
$className = get_class($this);
if (isset(self::$_assetPaths[$className]))
return self::$_assetPaths[$className];
else {
$viewPath = $this->getViewPath($checkTheme);
return self::$_assetPaths[$className] = substr_replace($viewPath, 'assets', strrpos($viewPath, 'views'), strlen('views'));
}
}
/**
* @param string $path
* @param boolean $hashByName
* @param integer $level
* @param boolean $forceCopy
* @return string an absolute URL to the published asset
* @throws CException if the asset to be published does not exist.
*/
public function publish($path, $hashByName, $level, $forceCopy) {
/* @var $assetManager CAssetManager */
$assetManager = Yii::app()->assetManager;
return $assetManager->publish($path, $hashByName, $level, $forceCopy);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment