aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity/Entry.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2015-02-20 20:29:33 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2015-03-06 20:50:30 +0100
commit0a018fe03980b35c9f7aca838e67a8efa43b7f2d (patch)
treed531ff5c3051871dd5315e26e50ec45c7da2b16b /src/Wallabag/CoreBundle/Entity/Entry.php
parent6d37a7e6c11666c2c220c9eb358a877f15bcfa0e (diff)
downloadwallabag-0a018fe03980b35c9f7aca838e67a8efa43b7f2d.tar.gz
wallabag-0a018fe03980b35c9f7aca838e67a8efa43b7f2d.tar.zst
wallabag-0a018fe03980b35c9f7aca838e67a8efa43b7f2d.zip
add relation between entry and tag
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Entry.php')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Entry.php27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php
index e47848b6..e0d1b839 100644
--- a/src/Wallabag/CoreBundle/Entity/Entry.php
+++ b/src/Wallabag/CoreBundle/Entity/Entry.php
@@ -2,6 +2,7 @@
2 2
3namespace Wallabag\CoreBundle\Entity; 3namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\Common\Collections\ArrayCollection;
5use Doctrine\ORM\Mapping as ORM; 6use Doctrine\ORM\Mapping as ORM;
6use Symfony\Component\Validator\Constraints as Assert; 7use Symfony\Component\Validator\Constraints as Assert;
7use Hateoas\Configuration\Annotation as Hateoas; 8use Hateoas\Configuration\Annotation as Hateoas;
@@ -118,12 +119,22 @@ class Entry
118 */ 119 */
119 private $user; 120 private $user;
120 121
122 /**
123 * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist", "merge"})
124 * @ORM\JoinTable(name="tags_entries",
125 * joinColumns={@ORM\JoinColumn(name="entry_id", referencedColumnName="id")},
126 * inverseJoinColumns={@ORM\JoinColumn(name="tag_id", referencedColumnName="id")}
127 * )
128 */
129 private $tags;
130
121 /* 131 /*
122 * @param User $user 132 * @param User $user
123 */ 133 */
124 public function __construct(User $user) 134 public function __construct(User $user)
125 { 135 {
126 $this->user = $user; 136 $this->user = $user;
137 $this->tags = new ArrayCollection();
127 } 138 }
128 139
129 /** 140 /**
@@ -381,4 +392,20 @@ class Entry
381 { 392 {
382 $this->isPublic = $isPublic; 393 $this->isPublic = $isPublic;
383 } 394 }
395
396 /**
397 * @return ArrayCollection<Tag>
398 */
399 public function getTags()
400 {
401 return $this->tags;
402 }
403
404 /**
405 * @param Tag $tag
406 */
407 public function addTag(Tag $tag)
408 {
409 $this->tags[] = $tag;
410 }
384} 411}