Doctrine Blameable:on =“change”在on =“create”和“update”时不起作用

时间:2015-01-14 08:53:39

标签: symfony doctrine-orm

我正在尝试将Doctrine的Extensions Blameable和Softdeleteable结合起来:当我执行$em->remove($myEntity);时,我希望相应地更新字段deleteddeletedBy

use Gedmo\Mapping\Annotation as Gedmo;

/**
 * @Gedmo\SoftDeleteable(fieldName="deleted", timeAware=false)
 */

[...]

/**
 * DateTime of softdeletion
 * @var \DateTime
 * 
 * @ORM\Column(name="deleted", type="datetime", nullable=true)
 * @Assert\DateTime()
 */
private $deleted;

/**
 * Softdeleted by
 * @var MyProject\UserBundle\Entity\User $deletedBy
 *
 * @Gedmo\Blameable(on="change", field="deleted")
 * @ORM\ManyToOne(targetEntity="MyProject\UserBundle\Entity\User")
 * @ORM\JoinColumn()
 */
private $deletedBy;

我对created / createdBy(使用Blameable(on="create"))和updated / updatedBy(使用Blameable(on="update"))进行了类似的配置。

即使更奇怪,如果我用上面的代码替换上面的代码,字段deletedBy也会正确更新:

/**
 * Softdeleted by
 * @var MyProject\UserBundle\Entity\User $deletedBy
 *
 * @Gedmo\Blameable(on="update")
 * @ORM\ManyToOne(targetEntity="MyProject\UserBundle\Entity\User")
 * @ORM\JoinColumn()
 */
private $deletedBy;

所以似乎只有Blameable(on="change", field="deleted")部分不起作用,我不知道为什么......

0 个答案:

没有答案