Created
September 13, 2012 02:18
-
-
Save petrabarus/3711430 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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