I have an entity (Server) that should have two extra fields: createdAt and updatedAt (like cakephp). I tried this on Server
entity:
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function updateTimestamp()
{
$this->setModifiedAt(new \DateTime());
if($this->getCreatedAt() == null){
$this->setCreatedAt(new \DateTime());
}
}
but nothing happened during update process. Then I searched about it and there was this EventListener
solution.
I couldn't fix it by that too.
is there any solution for this problem, please provide a step by step solution.
thank you a lot and sorry for bad English! ;)
Check you have the
HasLifecycleCallbacks
annotation on your entity, as example:Hope this help