Dinamicaly change module property

Hi. I try to change module properties which was set in configs.

For example. My config




'modules' => [

        'lazyloading' => [

            'class' => 'denar90\lazyloading\LazyLoading',

                    'modelNamespace' => '\common\models\Items',

            ]

       ]



Controller action. Where I call module. I want change value of modelNamespace




$lazyloading = \Yii::$app->getModule('lazyloading');

Yii::$app->params['modules']['lazyloading']['modelNamespace'] = '\common\models\Posts';

return $lazyloading->runAction('lazyloading/index');



Module action




public function actionIndex() {

$module = $this->module;

$items = new $module->modelNamespace; // always value '\common\models\Items\ I want to have '\common\models\Posts'

}



How I can change module properties? Thank you for answers.

You already have the model, so you can just change its property:




$lazyloading = \Yii::$app->getModule('lazyloading');

$lazyloading->modelNamespace = '\common\models\Posts';



Yii::$app->params is just a set of parameters you can configure in the config, this has nothing to do with modules or components.

But when when I call $lazyloading->runAction(‘lazyloading/index’); I am going to




public function actionIndex() {

$module = $this->module;

$items = new $module->modelNamespace;

}




And always have $this->module->modelNamespace value is '\common\models\Items\.