]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Tag.php
manage assets through npm
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Tag.php
index b4adbbd3eeffdb1e5ee774aa0027cac3d91475e2..4b480ff1cdc4f2c4ebc2b7e4bf4b558edb95eb9a 100644 (file)
@@ -98,9 +98,30 @@ class Tag
         return $this->slug;
     }
 
+    /**
+     * @param Entry $entry
+     */
     public function addEntry(Entry $entry)
     {
-        $this->entries[] = $entry;
+        if ($this->entries->contains($entry)) {
+            return;
+        }
+
+        $this->entries->add($entry);
+        $entry->addTag($this);
+    }
+
+    /**
+     * @param Entry $entry
+     */
+    public function removeEntry(Entry $entry)
+    {
+        if (!$this->entries->contains($entry)) {
+            return;
+        }
+
+        $this->entries->removeElement($entry);
+        $entry->removeTag($this);
     }
 
     public function hasEntry($entry)