]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Tag.php
add relation between user and tags, tests are broken
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Tag.php
index 1cdf4df027cc772dcbedf8f8923276ded593a77a..29a5e4b5eb69e1b2b07ef1bb49608afce7469e7a 100644 (file)
@@ -6,6 +6,7 @@ use Doctrine\ORM\Mapping as ORM;
 use JMS\Serializer\Annotation\XmlRoot;
 use JMS\Serializer\Annotation\ExclusionPolicy;
 use JMS\Serializer\Annotation\Expose;
+use Doctrine\Common\Collections\ArrayCollection;
 
 /**
  * Tag
@@ -36,10 +37,20 @@ class Tag
     private $label;
 
     /**
-     * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist", "merge"})
+     * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
      */
     private $entries;
 
+    /**
+     * @ORM\ManyToOne(targetEntity="User", inversedBy="tags")
+     */
+    private $user;
+
+    public function __construct(User $user)
+    {
+        $this->user    = $user;
+        $this->entries = new ArrayCollection();
+    }
     /**
      * Get id
      *
@@ -72,4 +83,9 @@ class Tag
     {
         return $this->label;
     }
+
+    public function addEntry(Entry $entry)
+    {
+        $this->entries[] = $entry;
+    }
 }