0
我想用克隆的Scenario對象創建Game對象。在SonataAdmin類中分配克隆對象
Create Game form:
Name: My game
Scenario: MyScenario (Combo box)
基礎上的答案Deep clone Doctrine entity with related entities的問題,我已經實現了__clone
方法。
我在GameAdmin
類中使用__clone
方法prePersist
方法。
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
非常感謝:
環路克隆每個
task
解決問題!幫我出去了。 :) –