I have declared a class
class MyClass extends Component {
public $prop1;
public $prop2;
public function __construct($param1, $param2, $config = [])
{
// ... initialization before configuration is applied
parent::__construct($config);
}
..............
Now, I can create instance of it by using
$component1 = new MyClass(1, 2, ['prop1' => 3, 'prop2' => 4]);
OR,
$component2 = \Yii::createObject([
'class' => MyClass::className(),
'prop1' => 13,
'prop2' => 40,
], [1, 2]);
Now, I want to register it as a application component. I can do that by doing following :
'components' => [
'myComponent' => [
'class' => 'frontend\components\MyComponent',
'prop1'=>3,
'prop2'=>7
],
But, when I register it as a application component, how can I pass values for $param1 and $param2 in the constructor ?
Thanks.