Files
wallabag/src/Helper/EntityTimestampsTrait.php

23 lines
397 B
PHP
Raw Normal View History

<?php
2024-02-19 01:30:12 +01:00
namespace Wallabag\Helper;
use Doctrine\ORM\Mapping as ORM;
/**
* Trait to handle created & updated date of an Entity.
*/
trait EntityTimestampsTrait
{
2025-04-05 12:55:51 +02:00
#[ORM\PrePersist]
#[ORM\PreUpdate]
public function timestamps()
{
if (null === $this->createdAt) {
$this->createdAt = new \DateTime();
}
$this->updatedAt = new \DateTime();
}
}