我想用克隆的场景对象创建游戏对象。
Create Game form:
Name: My game
Scenario: MyScenario (Combo box)
基于对带有相关实体问题的深度克隆学说实体的回答,我已经实现了__clone
方法。
我在课堂上的方法中使用__clone
方法。prePersist
GameAdmin
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
}
我不确定这是否适合进行此操作,因为我得到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