I am writing a duplicate action within Symfony and Doctrine..
What I want to accomplish is to just load the object, unset the id
and persist it again.
I was thinking of an example:
$A = $em->find('Some\Entity',1);
$B = clone $A;
$B->setId(null);
Is this the right way to do that?
Idea is to have an /duplicate
endpoint which will implement this logic. I saw that using __clone()
in the entity class would be the best way to go, but is there any workaround for my case?