Reputation: 31568
i am new to symfony2 and i am learning to use event listerners.
I have this code
/** @Entity @HasLifecycleCallbacks */
class User
{
// ...
/** @ORM\PrePersist */
public function setPassword()
{
$this->password = "EVENTS";
}
Now do i need anything else as well to make this code work. i mean what else do i need to do for this to work
Upvotes: 1
Views: 817
Reputation: 2310
@HasLifecycleCallbacks = to notify Doctrine that this entity has entity life-cycle callback annotations set on at least one of its methods
Possible annotations on the methods
@PostLoad, @PrePersist, @PostPersist, @PreRemove, @PostRemove, @PreUpdate or @PostUpdate
So, your code is good enough.
Upvotes: 2