I have a module that was written in Yii 1.x and am porting it to 2 (Bbii to be specific). I have this code in its Module class
/**
* Register the CSS and JS files for the module
*/
public function registerAssets() {
Yii::app()->clientScript->registerCssFile($this->getAssetsUrl() . '/css/' . $this->bbiiTheme . '/forum.css');
Yii::app()->getClientScript()->registerCoreScript('jquery.ui');
Yii::app()->clientScript->registerScriptFile($this->getAssetsUrl() . '/js/bbii.js', CClientScript::POS_HEAD);
}
for which I wrote a bundle class and I registered it and published as shown below. Now in the same code (Bbii Yii 1.x code) I have:
/**
* Retrieve url of image in the assets
* @param string filename of the image
* @return string source URL of image
*/
public function getRegisteredImage($filename) {
return $this->getAssetsUrl() .'/images/'. $filename;
}
So I have re-written code as
public function registerAssets()
{
$this->bundleInstance = \frontend\modules\bbii\BbiiAsset::register(\Yii::$app->view);
$this->bundleInstance->publish(\Yii::$app->assetManager);
}
public function getRegisteredImage($filename) {
return $this->bundleInstance->baseUrl .'/images/'. $filename;
}
But I get the frontend/web path from
$this->bundleInstance->baseUrl
instead of module path or at least assets path
I believe am doing something wrong here and would like to know what it is. So any help is appreciated!
TIA,
Steve