aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/UserBundle/Entity
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2017-07-06 09:00:37 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2017-07-06 09:01:51 +0200
commit927c9e796ff6fad2bf82a965234f52932cdee657 (patch)
treed53d021f2f2c301646d40113330fdd6692cb08c5 /src/Wallabag/UserBundle/Entity
parentb5d7eb148c4cd62ff187b08765f0c13c7d330fcf (diff)
downloadwallabag-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/UserBundle/Entity')
-rw-r--r--src/Wallabag/UserBundle/Entity/User.php16
1 files changed, 3 insertions, 13 deletions
diff --git a/src/Wallabag/UserBundle/Entity/User.php b/src/Wallabag/UserBundle/Entity/User.php
index 53c327f9..48446e3c 100644
--- a/src/Wallabag/UserBundle/Entity/User.php
+++ b/src/Wallabag/UserBundle/Entity/User.php
@@ -15,6 +15,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
15use Wallabag\ApiBundle\Entity\Client; 15use Wallabag\ApiBundle\Entity\Client;
16use Wallabag\CoreBundle\Entity\Config; 16use Wallabag\CoreBundle\Entity\Config;
17use Wallabag\CoreBundle\Entity\Entry; 17use Wallabag\CoreBundle\Entity\Entry;
18use Wallabag\CoreBundle\Helper\EntityTimestampsTrait;
18 19
19/** 20/**
20 * User. 21 * User.
@@ -29,6 +30,8 @@ use Wallabag\CoreBundle\Entity\Entry;
29 */ 30 */
30class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface 31class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterface
31{ 32{
33 use EntityTimestampsTrait;
34
32 /** @Serializer\XmlAttribute */ 35 /** @Serializer\XmlAttribute */
33 /** 36 /**
34 * @var int 37 * @var int
@@ -139,19 +142,6 @@ class User extends BaseUser implements TwoFactorInterface, TrustedComputerInterf
139 } 142 }
140 143
141 /** 144 /**
142 * @ORM\PrePersist
143 * @ORM\PreUpdate
144 */
145 public function timestamps()
146 {
147 if (null === $this->createdAt) {
148 $this->createdAt = new \DateTime();
149 }
150
151 $this->updatedAt = new \DateTime();
152 }
153
154 /**
155 * Set name. 145 * Set name.
156 * 146 *
157 * @param string $name 147 * @param string $name