X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FEntry.php;h=75aeae84bffff83d0124f2c3d06172e82d047240;hb=092ca70725b0263390e45c46f93828c613eca3f0;hp=e47848b61d9bd93bf9105af7d63a23ac43d6ca49;hpb=1d14779154481b320e1c44fccf2558d8c9fa43a1;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Entry.php b/src/Wallabag/CoreBundle/Entity/Entry.php index e47848b6..75aeae84 100644 --- a/src/Wallabag/CoreBundle/Entity/Entry.php +++ b/src/Wallabag/CoreBundle/Entity/Entry.php @@ -2,6 +2,7 @@ namespace Wallabag\CoreBundle\Entity; +use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Hateoas\Configuration\Annotation as Hateoas; @@ -118,12 +119,19 @@ class Entry */ private $user; + /** + * @ORM\ManyToMany(targetEntity="Tag", inversedBy="entries", cascade={"persist"}) + * @ORM\JoinTable(name="entry_tags") + */ + private $tags; + /* * @param User $user */ public function __construct(User $user) { $this->user = $user; + $this->tags = new ArrayCollection(); } /** @@ -381,4 +389,26 @@ class Entry { $this->isPublic = $isPublic; } + + /** + * @return ArrayCollection + */ + public function getTags() + { + return $this->tags; + } + + /** + * @param Tag $tag + */ + public function addTag(Tag $tag) + { + $this->tags[] = $tag; + $tag->addEntry($this); + } + + public function removeTag(Tag $tag) + { + $this->tags->removeElement($tag); + } }