]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Entry.php
add relation between user and tags, tests are broken
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Entry.php
index 4f57eb0afcfbe993d211aab06041eb97a4866ea1..75aeae84bffff83d0124f2c3d06172e82d047240 100644 (file)
@@ -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;
@@ -57,13 +58,6 @@ class Entry
      */
     private $isStarred = false;
 
-    /**
-     * @var boolean
-     *
-     * @ORM\Column(name="is_deleted", type="boolean")
-     */
-    private $isDeleted = false;
-
     /**
      * @var string
      *
@@ -125,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();
     }
 
     /**
@@ -280,22 +281,6 @@ class Entry
         return $this->user;
     }
 
-    /**
-     * @return string
-     */
-    public function isDeleted()
-    {
-        return $this->isDeleted;
-    }
-
-    /**
-     * @param string $isDeleted
-     */
-    public function setDeleted($isDeleted)
-    {
-        $this->isDeleted = $isDeleted;
-    }
-
     /**
      * @return string
      */
@@ -404,4 +389,26 @@ class Entry
     {
         $this->isPublic = $isPublic;
     }
+
+    /**
+     * @return ArrayCollection<Tag>
+     */
+    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);
+    }
 }