SonataAdminBundle-检查`preUpdate`挂钩中的更改 [英] SonataAdminBundle - check changes in `preUpdate` hook
本文介绍了SonataAdminBundle-检查`preUpdate`挂钩中的更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以检查 preUpdate
挂钩?我正在寻找类似 preUpdate
hasChangedField($ fieldName)
教义功能。有任何想法吗?
Is it possible to check if field was changed on preUpdate
hook? I'm looking for something like preUpdate
hasChangedField($fieldName)
Doctrine functionality. Any ideas?
推荐答案
此问题与这一个
您的解决方案只是比较领域
Your solution is just to compare the field of the old object with the new one and see where it differs.
因此,例如:
public function preUpdate($newObject)
{
$em = $this->getModelManager()->getEntityManager($this->getClass());
$originalObject = $em->getUnitOfWork()->getOriginalEntityData($newObject);
if ($newObject->getSomeField() !== $originalObject['fieldName']) {
// Field has been changed
}
}
这篇关于SonataAdminBundle-检查`preUpdate`挂钩中的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文