I want to create Game object with cloned Scenario object.
Create Game form:
Name: My game
Scenario: MyScenario (Combo box)
Basing on answer for Deep clone Doctrine entity with related entities question I have implemented __clone
methods.
I'm using __clone
method in prePersist
method in GameAdmin
class.
public function prePersist($game)
{
$user = $this->container->get('security.context')->getToken()->getUser();
$game->setAuthor($user);
$cp = clone $game->getScenario(); //Error after add this
$game->setScenario($cp); //two lines
}
I'm not sure is this a proper place for doing this operation because I'm getting MappingException
:
The class 'Doctrine\ORM\Persisters\ManyToManyPersister' was not found in the chain
configured namespaces Sonata\MediaBundle\Entity, FOS\UserBundle\Entity,
Sonata\UserBundle\Entity, Application\Sonata\MediaBundle\Entity,
Application\Sonata\UserBundle\Entity, GM\AppBundle\Entity