我有一个事件 preFlush:
/**
* On flush event
*
* @param PreFlushEventArgs $event
*/
public function preFlush(PreFlushEventArgs $event)
{
$em = $event->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
if ($entity instanceof Answer) {
// Set last answered
$question = $entity->getQuestion();
$question->setChanged(new \DateTime('now'));
$uow->persist($question);
}
}
}
我想检查设置问题。尝试创建模拟 UnitOfWork,方法 - 坚持,但这不起作用,因为答案对象未设置为“UOW:entityInsertions”。