mirror of
https://github.com/wallabag/wallabag.git
synced 2024-09-27 05:50:02 +00:00
927c9e796f
Refactorize timestamps() method to avoid re-writing it on each entity
24 lines
426 B
PHP
24 lines
426 B
PHP
<?php
|
|
|
|
namespace Wallabag\CoreBundle\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();
|
|
}
|
|
}
|