草庐IT

PrePersist

全部标签

php - Doctrine 2 PrePersist 不会触发

在同一个实体中,我有一个PreUpdate和一个PrePersist。PreUpdate触发,但PrePersist从不触发。我在生命周期回调中的刷新和注释之后放置了一个die()。完整实体可见于http://pastebin.com/yUk1u4GQ实体回调/***@PreUpdate*/publicfunctionfixDates(){$this->updatedOn=$this->getNow();$this->closedDate=null;$this->openDate=null;print"datesfixed";}/***@PrePersist*/publicfuncti

php - 在 Symfony2 中将 SecurityContext 注入(inject)监听器 prePersist 或 preUpdate 以获取 createdBy 或 updatedBy 中的用户导致循环引用错误

我设置了一个监听器类,我将在其中设置任何doctrineprePersist的ownerid列。我的services.yml文件看起来像这样......services:my.listener:class:App\SharedBundle\Listener\EntityListenerarguments:["@security.context"]tags:-{name:doctrine.event_listener,event:prePersist}我的类(class)看起来像这样......useDoctrine\ORM\Event\LifecycleEventArgs;useSym
12