forked from wallabag/wallabag
Add EntityTimestampsTrait to handle dates
Refactorize timestamps() method to avoid re-writing it on each entity
This commit is contained in:
@ -4,6 +4,7 @@ namespace Wallabag\CoreBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
|
||||
use Wallabag\UserBundle\Entity\User;
|
||||
|
||||
/**
|
||||
@ -15,6 +16,8 @@ use Wallabag\UserBundle\Entity\User;
|
||||
*/
|
||||
class SiteCredential
|
||||
{
|
||||
use EntityTimestampsTrait;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
@ -182,14 +185,4 @@ class SiteCredential
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PrePersist
|
||||
*/
|
||||
public function timestamps()
|
||||
{
|
||||
if (null === $this->createdAt) {
|
||||
$this->createdAt = new \DateTime();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user