How do I setup a join table with extra columns, or a many-to-many association with additional properties, in Doctrine 2?
In the second article, I suggest a minor update. Instead of the full event, use a LifecycleCallback within the entity itself:
/**
* @ORM\Entity
* @ORM\Table(name="jobs”)
* @ORM\HasLifecycleCallbacks
*/
class Job
{
// ...
/**
* @ORM\PreRemove
*/
public function preRemoveCallback()
{
$this->setPerson(null);
$this->setCompany(null);
}
}