So I'm creating a doctrine entity, called exhibitors. This entity has relationships to 2 other entities, both are ManyToMany relationships. They are Quotes and Services.
When I clone the exhibitor, it also clones all existing quotes and services with new ids.
Is there a way I can prevent the relations cloning as well, I just want to clone the Exhibitor?
Does anyone know?
At present I'm just doing
* $newExhibitor = clone $exhibitor;
$this->entityManager->getEntityManager()->persist($newExhibitor);
$this->entityManager->getEntityManager()->flush();*
Why do you clone an exhibitor ? Do you need 2 identical Exhibitor in your database ? Did you try setting to null before persist ?:
$newExhibitor = clone $exhibitor;
$newExhibitor->setQuotes(null);
$newExhibitor->setServices(null);
$this->entityManager->getEntityManager()->persist($newExhibitor);
$this->entityManager->getEntityManager()->flush();