diff options
author | Paulino Michelazzo <paulino@michelazzo.com.br> | 2016-10-18 22:48:23 +0200 |
---|---|---|
committer | Paulino Michelazzo <paulino@michelazzo.com.br> | 2016-10-18 22:48:23 +0200 |
commit | 99731f0bb1f6fd2815eeb9af504ce86df927657b (patch) | |
tree | b080efc608d2bbd52b77a4a0067402007f50c5a8 /src/Wallabag/CoreBundle/Entity/Entry.php | |
parent | 3a3c6b866b52721431bed22426d9abfcd0d2dfe0 (diff) | |
parent | 7180aaed45dce62e40620a9e4b202526ebd6a3bb (diff) | |
download | wallabag-99731f0bb1f6fd2815eeb9af504ce86df927657b.tar.gz wallabag-99731f0bb1f6fd2815eeb9af504ce86df927657b.tar.zst wallabag-99731f0bb1f6fd2815eeb9af504ce86df927657b.zip |
Merge remote-tracking branch 'wallabag/master'
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 86 |
1 files changed, 78 insertions, 8 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index ceae78b0..f2da3f4d 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -40,6 +40,15 @@ class Entry | |||
40 | /** | 40 | /** |
41 | * @var string | 41 | * @var string |
42 | * | 42 | * |
43 | * @ORM\Column(name="uuid", type="text", nullable=true) | ||
44 | * | ||
45 | * @Groups({"entries_for_user", "export_all"}) | ||
46 | */ | ||
47 | private $uuid; | ||
48 | |||
49 | /** | ||
50 | * @var string | ||
51 | * | ||
43 | * @ORM\Column(name="title", type="text", nullable=true) | 52 | * @ORM\Column(name="title", type="text", nullable=true) |
44 | * | 53 | * |
45 | * @Groups({"entries_for_user", "export_all"}) | 54 | * @Groups({"entries_for_user", "export_all"}) |
@@ -88,20 +97,20 @@ class Entry | |||
88 | private $content; | 97 | private $content; |
89 | 98 | ||
90 | /** | 99 | /** |
91 | * @var date | 100 | * @var \DateTime |
92 | * | 101 | * |
93 | * @ORM\Column(name="created_at", type="datetime") | 102 | * @ORM\Column(name="created_at", type="datetime") |
94 | * | 103 | * |
95 | * @Groups({"export_all"}) | 104 | * @Groups({"entries_for_user", "export_all"}) |
96 | */ | 105 | */ |
97 | private $createdAt; | 106 | private $createdAt; |
98 | 107 | ||
99 | /** | 108 | /** |
100 | * @var date | 109 | * @var \DateTime |
101 | * | 110 | * |
102 | * @ORM\Column(name="updated_at", type="datetime") | 111 | * @ORM\Column(name="updated_at", type="datetime") |
103 | * | 112 | * |
104 | * @Groups({"export_all"}) | 113 | * @Groups({"entries_for_user", "export_all"}) |
105 | */ | 114 | */ |
106 | private $updatedAt; | 115 | private $updatedAt; |
107 | 116 | ||
@@ -187,8 +196,6 @@ class Entry | |||
187 | * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") | 196 | * @ORM\JoinColumn(name="tag_id", referencedColumnName="id") |
188 | * } | 197 | * } |
189 | * ) | 198 | * ) |
190 | * | ||
191 | * @Groups({"entries_for_user", "export_all"}) | ||
192 | */ | 199 | */ |
193 | private $tags; | 200 | private $tags; |
194 | 201 | ||
@@ -401,7 +408,22 @@ class Entry | |||
401 | } | 408 | } |
402 | 409 | ||
403 | /** | 410 | /** |
404 | * @return string | 411 | * Set created_at. |
412 | * Only used when importing data from an other service. | ||
413 | * | ||
414 | * @param \DateTime $createdAt | ||
415 | * | ||
416 | * @return Entry | ||
417 | */ | ||
418 | public function setCreatedAt(\DateTime $createdAt) | ||
419 | { | ||
420 | $this->createdAt = $createdAt; | ||
421 | |||
422 | return $this; | ||
423 | } | ||
424 | |||
425 | /** | ||
426 | * @return \DateTime | ||
405 | */ | 427 | */ |
406 | public function getCreatedAt() | 428 | public function getCreatedAt() |
407 | { | 429 | { |
@@ -409,7 +431,7 @@ class Entry | |||
409 | } | 431 | } |
410 | 432 | ||
411 | /** | 433 | /** |
412 | * @return string | 434 | * @return \DateTime |
413 | */ | 435 | */ |
414 | public function getUpdatedAt() | 436 | public function getUpdatedAt() |
415 | { | 437 | { |
@@ -518,6 +540,21 @@ class Entry | |||
518 | } | 540 | } |
519 | 541 | ||
520 | /** | 542 | /** |
543 | * @VirtualProperty | ||
544 | * @SerializedName("tags") | ||
545 | * @Groups({"entries_for_user", "export_all"}) | ||
546 | */ | ||
547 | public function getSerializedTags() | ||
548 | { | ||
549 | $data = []; | ||
550 | foreach ($this->tags as $tag) { | ||
551 | $data[] = $tag->getLabel(); | ||
552 | } | ||
553 | |||
554 | return $data; | ||
555 | } | ||
556 | |||
557 | /** | ||
521 | * @param Tag $tag | 558 | * @param Tag $tag |
522 | */ | 559 | */ |
523 | public function addTag(Tag $tag) | 560 | public function addTag(Tag $tag) |
@@ -595,4 +632,37 @@ class Entry | |||
595 | { | 632 | { |
596 | return $this->language; | 633 | return $this->language; |
597 | } | 634 | } |
635 | |||
636 | /** | ||
637 | * @return string | ||
638 | */ | ||
639 | public function getUuid() | ||
640 | { | ||
641 | return $this->uuid; | ||
642 | } | ||
643 | |||
644 | /** | ||
645 | * @param string $uuid | ||
646 | * | ||
647 | * @return Entry | ||
648 | */ | ||
649 | public function setUuid($uuid) | ||
650 | { | ||
651 | $this->uuid = $uuid; | ||
652 | |||
653 | return $this; | ||
654 | } | ||
655 | |||
656 | public function generateUuid() | ||
657 | { | ||
658 | if (null === $this->uuid) { | ||
659 | // @see http://blog.kevingomez.fr/til/2015/07/26/why-is-uniqid-slow/ for true parameter | ||
660 | $this->uuid = uniqid('', true); | ||
661 | } | ||
662 | } | ||
663 | |||
664 | public function cleanUuid() | ||
665 | { | ||
666 | $this->uuid = null; | ||
667 | } | ||
598 | } | 668 | } |