How to initialize a component with an array

Hi,

In the main config file there are configuration for components like:

‘component’ =>

[

‘class’ => ‘\namespace\to\class’,

‘param1’ => ‘somevalue’,

‘param2’ => ‘somevalue’,

]

how I can do what Yii do in my own module, give an array of component file and module create and instance and initialize it?!

I have solved the problem myself so put answer if someone else have this problem use it:




$config = ['class' => 'someNameSpace\to\Class','property1'=>'john'];

$class = $config['class'];

unset($config['class']);

$componet = Yii::createObject($class,[$config]);