diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r-- | src/Wallabag/CoreBundle/Entity/Entry.php | 59 |
1 files changed, 35 insertions, 24 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index 937213b4..75aeae84 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php | |||
@@ -2,19 +2,24 @@ | |||
2 | 2 | ||
3 | namespace Wallabag\CoreBundle\Entity; | 3 | namespace Wallabag\CoreBundle\Entity; |
4 | 4 | ||
5 | use Doctrine\Common\Collections\ArrayCollection; | ||
5 | use Doctrine\ORM\Mapping as ORM; | 6 | use Doctrine\ORM\Mapping as ORM; |
6 | use Symfony\Component\Validator\Constraints as Assert; | 7 | use Symfony\Component\Validator\Constraints as Assert; |
8 | use Hateoas\Configuration\Annotation as Hateoas; | ||
9 | use JMS\Serializer\Annotation\XmlRoot; | ||
7 | 10 | ||
8 | /** | 11 | /** |
9 | * Entry | 12 | * Entry |
10 | * | 13 | * |
14 | * @XmlRoot("entry") | ||
11 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository") | 15 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\EntryRepository") |
12 | * @ORM\Table(name="entry") | 16 | * @ORM\Table(name="entry") |
13 | * @ORM\HasLifecycleCallbacks() | 17 | * @ORM\HasLifecycleCallbacks() |
14 | * | 18 | * @Hateoas\Relation("self", href = "expr('/api/entries/' ~ object.getId())") |
15 | */ | 19 | */ |
16 | class Entry | 20 | class Entry |
17 | { | 21 | { |
22 | /** @Serializer\XmlAttribute */ | ||
18 | /** | 23 | /** |
19 | * @var integer | 24 | * @var integer |
20 | * | 25 | * |
@@ -54,13 +59,6 @@ class Entry | |||
54 | private $isStarred = false; | 59 | private $isStarred = false; |
55 | 60 | ||
56 | /** | 61 | /** |
57 | * @var boolean | ||
58 | * | ||
59 | * @ORM\Column(name="is_deleted", type="boolean") | ||
60 | */ | ||
61 | private $isDeleted = false; | ||
62 | |||
63 | /** | ||
64 | * @var string | 62 | * @var string |
65 | * | 63 | * |
66 | * @ORM\Column(name="content", type="text", nullable=true) | 64 | * @ORM\Column(name="content", type="text", nullable=true) |
@@ -121,12 +119,19 @@ class Entry | |||
121 | */ | 119 | */ |
122 | private $user; | 120 | private $user; |
123 | 121 | ||
122 | /** | ||
123 | * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) | ||
124 | * @ORM\JoinTable(name="entry_tags") | ||
125 | */ | ||
126 | private $tags; | ||
127 | |||
124 | /* | 128 | /* |
125 | * @param User $user | 129 | * @param User $user |
126 | */ | 130 | */ |
127 | public function __construct(User $user) | 131 | public function __construct(User $user) |
128 | { | 132 | { |
129 | $this->user = $user; | 133 | $this->user = $user; |
134 | $this->tags = new ArrayCollection(); | ||
130 | } | 135 | } |
131 | 136 | ||
132 | /** | 137 | /** |
@@ -279,22 +284,6 @@ class Entry | |||
279 | /** | 284 | /** |
280 | * @return string | 285 | * @return string |
281 | */ | 286 | */ |
282 | public function isDeleted() | ||
283 | { | ||
284 | return $this->isDeleted; | ||
285 | } | ||
286 | |||
287 | /** | ||
288 | * @param string $isDeleted | ||
289 | */ | ||
290 | public function setDeleted($isDeleted) | ||
291 | { | ||
292 | $this->isDeleted = $isDeleted; | ||
293 | } | ||
294 | |||
295 | /** | ||
296 | * @return string | ||
297 | */ | ||
298 | public function getCreatedAt() | 287 | public function getCreatedAt() |
299 | { | 288 | { |
300 | return $this->createdAt; | 289 | return $this->createdAt; |
@@ -400,4 +389,26 @@ class Entry | |||
400 | { | 389 | { |
401 | $this->isPublic = $isPublic; | 390 | $this->isPublic = $isPublic; |
402 | } | 391 | } |
392 | |||
393 | /** | ||
394 | * @return ArrayCollection<Tag> | ||
395 | */ | ||
396 | public function getTags() | ||
397 | { | ||
398 | return $this->tags; | ||
399 | } | ||
400 | |||
401 | /** | ||
402 | * @param Tag $tag | ||
403 | */ | ||
404 | public function addTag(Tag $tag) | ||
405 | { | ||
406 | $this->tags[] = $tag; | ||
407 | $tag->addEntry($this); | ||
408 | } | ||
409 | |||
410 | public function removeTag(Tag $tag) | ||
411 | { | ||
412 | $this->tags->removeElement($tag); | ||
413 | } | ||
403 | } | 414 | } |