Reputation: 2524
I have 2 modules.
Config with ConfigEntity and Reporting with ReportingEntity
Those entities have a oneToManyRelation:
class Config
{
public function __construct()
{
$this->reportings = new ArrayCollection();
}
/**
* @ORM\OneToMany(targetEntity="Reporting\Entity\ConfigReporting",
* mappedBy="config", cascade={"persist"}, orphanRemoval=true)
*/
protected $reportings;
}
class ConfigReporting
{
/**
* @var int|null
* @ORM\ManyToOne(targetEntity="Config\Entity\Config", inversedBy="reportings")
* @ORM\JoinColumn(name="config", referencedColumnName="idConfig", onDelete="CASCADE")
*/
protected $config;
}
My module Reporting depends on Config's module to work. But with this doctrine's mapping, do i have a circular dependancy ?
If yes, do i have to declare the Reporting entity into Config module ?
Upvotes: 0
Views: 77
Reputation: 44326
This should not be a problem.
Did you try to setup the classes like you show? Did you run into any problems?
You can change your mapping to Unidirectional. Then you can turn of your Reporting module without problems. The disadvantage is that your Config
entity will not be aware of the association...
class Config
{
public function __construct()
{
}
}
class ConfigReporting
{
/**
* Unidirectional mapping owning side.
*
* @var int|null
* @ORM\ManyToOne(targetEntity="Config\Entity\Config")
* @ORM\JoinColumn(name="config", referencedColumnName="idConfig", onDelete="CASCADE")
*/
protected $config;
}
Upvotes: 1