wallabag/src/Helper/EntityTimestampsTrait.php
2024-02-23 07:42:48 +01:00

25 lines
415 B
PHP

<?php
namespace Wallabag\Helper;
use Doctrine\ORM\Mapping as ORM;
/**
* Trait to handle created & updated date of an Entity.
*/
trait EntityTimestampsTrait
{
/**
* @ORM\PrePersist
* @ORM\PreUpdate
*/
public function timestamps()
{
if (null === $this->createdAt) {
$this->createdAt = new \DateTime();
}
$this->updatedAt = new \DateTime();
}
}