I was using ActiveRecord models by defining relationships between them in Yii2 framework. Now I am trying to use dependency injection container with my ActiveRecord models and want to inject my dependencies. But circular dependency issue is confusing me.
If we define our relationships like explained Here, won't we end up having circular dependency issue? or I am missing something?
Thanks for any help and pointers.
Edit: Code Example from my models.
class NavMenu extends \yii\db\ActiveRecord {
public function getNavItemMenu() {
return $this->hasOne(NavItemMenu::className(), ['id' => 'nav_item_menu_id' ]);
}
}
class NavItemMenu extends \yii\db\ActiveRecord {
public function getNavMenus() {
return $this->hasMany(NavMenu::className(), ['nav_item_menu_id' => 'id' ]);
}
}
Above code is simplified just to give you the idea of the problem.