Commit 24a2c1d2 authored by Mat's avatar Mat
Browse files

événements prePersist et preUpdate sur les dates de Legume

parent 50f7f9ba
......@@ -11,6 +11,7 @@ use Vich\UploaderBundle\Mapping\Annotation as Vich;
*
* @ORM\Table(name="legume")
* @ORM\Entity(repositoryClass="PotageBundle\Repository\LegumeRepository")
* @ORM\HasLifecycleCallbacks()
* @Vich\Uploadable
*/
class Legume
......@@ -82,7 +83,14 @@ class Legume
/**
* @ORM\Column(type="datetime")
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime")
*/
private $createdAt;
/**
* @ORM\Column(name="updated_at", type="datetime")
* @var \DateTime
*/
private $updatedAt;
......@@ -109,6 +117,24 @@ class Legume
$this->id = null;
}
/**
*
* @ORM\PrePersist()
*/
public function prePersist()
{
$this->createdAt = new \DateTime();
//$this->updatedAt = new \DateTime();
}
/**
*
* @ORM\PreUpdate()
*/
public function preUpdate()
{
$this->updatedAt = new \DateTime();
}
/**
* Get id
*
......@@ -339,4 +365,52 @@ class Legume
return $this->image;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Legume
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Legume
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment