php - How in Yii 2 access AR object as component? -
actually, want have access ar object in anywere. want access ojb yii component.
like yii using user: yii::$app->user->identity - user component contains user ar object.
i want store page ar in component. so, it's something: yii::$app->page->page - page ar propery of page component. not nice :(. way?
in config can set it. user set , adapt requirements.
$config = [     ...     'components'=>[         ....         'user' => [             'class'=>'yii\web\user',             'identityclass' => 'common\models\user',             ...         ],         ...     ], ... ]; read more in yii2 documentation on link
Comments
Post a Comment