Doctrine orm doctrine2获取有关更新字段的信息

Doctrine orm doctrine2获取有关更新字段的信息,doctrine-orm,unit-of-work,Doctrine Orm,Unit Of Work,嗨,我想弄清楚控制器中哪个字段被更新了,我没有发现任何听起来像我在UnitOfWork的API文档中试图实现的东西。 例如,我想添加与此类似的@PreUpdate代码 /** @PreUpdate */ function updateAllIsDefaultFields(){ //only if $this->isDefault propery for this entity is changed to 1 from its previous state, then update

嗨,我想弄清楚控制器中哪个字段被更新了,我没有发现任何听起来像我在UnitOfWork的API文档中试图实现的东西。 例如,我想添加与此类似的@PreUpdate代码

/** @PreUpdate */ 
function updateAllIsDefaultFields(){
    //only if $this->isDefault propery for this entity is changed to 1 from its previous state, then update all other entities so they all have isDefault to 0

//else, means that this field is not changed, don't do anything

    }
或者每次操作都必须由控制器执行

我知道只要$this->isDefault设置为1,我每次都可以这样做,但为了性能,我希望避免使用它,我可能会发现它对其他一些场景也很有用。 提前感谢

有一些对医生有益的建议2。这是一个与你的案例类似的例子。

你必须写一份报告。可能使用
onFlush
事件,您可以从UnitOfWork中检索实体变更集,以确定某个字段是否已更新,然后执行所需的操作