How use Yii::$app->session['somename']
in yii2 assetmanager?
How make access some function in assetmanager?
class AppAsset extends AssetBundle{
public function getLang() {
$currentLang = Yii::$app->session['lang'];
if ($currentLang == 'fa' || $currentLang == 'ar') {
return 'RTL';
} else {
return 'LTR';
}
}
public $lang;
public $basePath = '@webroot';
public $baseUrl = '@web';
public $css = [
'css/iconSprite.min.css',
// how call getLang here
]
How call getLang
in css part?
You can do it like this
.. other functions
public function init() {
$this->setupAssets();
parent::init();
}
protected function setupAssets() {
$lang = $this->getLang();
$this->css[] = "css/myfile.$lang.css";
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With