diff options
author | Jérémy Benoist <j0k3r@users.noreply.github.com> | 2017-10-23 11:09:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 11:09:17 +0200 |
commit | 1953a872932a63792293b4aec087880265ba89f7 (patch) | |
tree | fd16599e737fcdaf193c933ef3ec4a4ee248b117 /src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php | |
parent | d83d25dadec2c38460a32d96f5d2903426fec9d3 (diff) | |
parent | 702f2d67d60ca963492b90dad74cb5f8dcc84e51 (diff) | |
download | wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.gz wallabag-1953a872932a63792293b4aec087880265ba89f7.tar.zst wallabag-1953a872932a63792293b4aec087880265ba89f7.zip |
Merge pull request #3011 from wallabag/2.3
wallabag 2.3.0
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/EntityTimestampsTrait.php')
-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 | } | ||