Reputation: 1422
I want to access session or Yii::$app
in config file like ( config/main.php
or config/main-local.php
) !
Is that possible or not?
I want to check session and make some style available!
'components' => [
'assetManager' => [
'assetMap' => [
'r.css' => Yii::$app->session['lang'] ? 'css/styleltr.css' : 'css/stylertl.css' ,
],
],
or how do something like that in assetmanager????
Upvotes: 4
Views: 382
Reputation:
You can't access user session in your config file. But, you could use a conditional in your layout and register different assets based on session values.
Upvotes: 2
Reputation: 133360
try accessing what you need this way
\Yii::$app->getAssetManager()->assetMap;
Upvotes: 0