Hi,
I’d like to ask how can I use DI for models extend ActiveRecord?
My intention is to create one object with dependency chain.
I have Class A, Class B, Class C and Class D. Class A contains Class B, Class B uses Class C and Class D.
class A extends \yii\db\ActiveRecord{
private $b;
public function __construct(B b, $config){
parent::_construct($config);
$this->b = b;
}
}
class B extends \yii\db\ActiveRecord{
private $c;
private $d;
public function __construct(C c,D d, $config){
parent::_construct($config);
$this->c = c;
$this->d = d;
}
public function f1(){
//...//
}
}
///controller//
public function actionDoA() {
$container = new Container();
$aObject = $container->get('A');
$sth = $aObject->b->f1();
}
After action execute there is no error, only blank page.
How should it be implemented?
Thx for help.