php - use custom function in assetmanager -
how use yii::$app->session['somename']
in yii2 assetmanager?
how make access 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 this
.. other functions public function init() { $this->setupassets(); parent::init(); } protected function setupassets() { $lang = $this->getlang(); $this->css[] = "css/myfile.$lang.css"; }
Comments
Post a Comment