我对doctrine listener [onFlush]有问题。我需要更新包含在事务中的其他实体。当我像这个例子一样使用时,更新在事务之前运行。可以帮助我吗?
public function onFlush(OnFlushEventArgs $args)
{
$ea = $this->getEventAdapter($args);
$om = $ea->getObjectManager();
$uow = $om->getUnitOfWork();
foreach ($ea->getScheduledObjectUpdates($uow) as $object) {
//... some operation on entity
$uow->propertyChanged($object, 'field', 'oldValue', 'newValue');
//...........................
// global update with createQueryBuilder on another entities
// I need added this also to transaction
$qb = $om->createQueryBuilder();
$qb->update(".........")
->set(".........")
->where(".........")
->getQuery()
->execute();
}
}