diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-07-11 07:30:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-11 07:30:08 +0200 |
commit | 9aa11176b89ab99c267c1d2353ef645c817c941d (patch) | |
tree | 4e6ddf6e2b76dfd76d0912e94d62a73aaa331685 /src/Wallabag/CoreBundle/Helper | |
parent | 337e807297fb9700407ce6e4c4f7c307b4dae22c (diff) | |
parent | 927c9e796ff6fad2bf82a965234f52932cdee657 (diff) | |
download | wallabag-9aa11176b89ab99c267c1d2353ef645c817c941d.tar.gz wallabag-9aa11176b89ab99c267c1d2353ef645c817c941d.tar.zst wallabag-9aa11176b89ab99c267c1d2353ef645c817c941d.zip |
Merge pull request #3264 from wallabag/trait-timestamps
Add EntityTimestampsTrait to handle dates
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php b/src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php new file mode 100644 index 00000000..1b1ff54a --- /dev/null +++ b/src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php | |||
@@ -0,0 +1,24 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | |||
7 | /** | ||
8 | * Trait to handle created & updated date of an Entity. | ||
9 | */ | ||
10 | trait EntityTimestampsTrait | ||
11 | { | ||
12 | /** | ||
13 | * @ORM\PrePersist | ||
14 | * @ORM\PreUpdate | ||
15 | */ | ||
16 | public function timestamps() | ||
17 | { | ||
18 | if (null === $this->createdAt) { | ||
19 | $this->createdAt = new \DateTime(); | ||
20 | } | ||
21 | |||
22 | $this->updatedAt = new \DateTime(); | ||
23 | } | ||
24 | } | ||