diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-07-06 09:00:37 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2017-07-06 09:01:51 +0200 |
commit | 927c9e796ff6fad2bf82a965234f52932cdee657 (patch) | |
tree | d53d021f2f2c301646d40113330fdd6692cb08c5 /src/Wallabag/CoreBundle/Entity/Entry.php | |
parent | b5d7eb148c4cd62ff187b08765f0c13c7d330fcf (diff) | |
download | wallabag-927c9e796ff6fad2bf82a965234f52932cdee657.tar.gz wallabag-927c9e796ff6fad2bf82a965234f52932cdee657.tar.zst wallabag-927c9e796ff6fad2bf82a965234f52932cdee657.zip |
Add EntityTimestampsTrait to handle dates
Refactorize timestamps() method to avoid re-writing it on each entity
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index cba72d31..61d01bdc 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -12,6 +12,7 @@ use JMS\Serializer\Annotation\VirtualProperty; | |||
12 | use JMS\Serializer\Annotation\XmlRoot; | 12 | use JMS\Serializer\Annotation\XmlRoot; |
13 | use Symfony\Component\Validator\Constraints as Assert; | 13 | use Symfony\Component\Validator\Constraints as Assert; |
14 | use Wallabag\AnnotationBundle\Entity\Annotation; | 14 | use Wallabag\AnnotationBundle\Entity\Annotation; |
15 | use Wallabag\CoreBundle\Helper\EntityTimestampsTrait; | ||
15 | use Wallabag\UserBundle\Entity\User; | 16 | use Wallabag\UserBundle\Entity\User; |
16 | 17 | ||
17 | /** | 18 | /** |
@@ -32,6 +33,8 @@ use Wallabag\UserBundle\Entity\User; | |||
32 | */ | 33 | */ |
33 | class Entry | 34 | class Entry |
34 | { | 35 | { |
36 | use EntityTimestampsTrait; | ||
37 | |||
35 | /** @Serializer\XmlAttribute */ | 38 | /** @Serializer\XmlAttribute */ |
36 | /** | 39 | /** |
37 | * @var int | 40 | * @var int |
@@ -473,19 +476,6 @@ class Entry | |||
473 | } | 476 | } |
474 | 477 | ||
475 | /** | 478 | /** |
476 | * @ORM\PrePersist | ||
477 | * @ORM\PreUpdate | ||
478 | */ | ||
479 | public function timestamps() | ||
480 | { | ||
481 | if (null === $this->createdAt) { | ||
482 | $this->createdAt = new \DateTime(); | ||
483 | } | ||
484 | |||
485 | $this->updatedAt = new \DateTime(); | ||
486 | } | ||
487 | |||
488 | /** | ||
489 | * @return ArrayCollection<Annotation> | 479 | * @return ArrayCollection<Annotation> |
490 | */ | 480 | */ |
491 | public function getAnnotations() | 481 | public function getAnnotations() |