X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=src%2FWallabag%2FCoreBundle%2FEntity%2FTag.php;h=4b480ff1cdc4f2c4ebc2b7e4bf4b558edb95eb9a;hb=5ecdfcd041767c9e3244a92bb0a6cc3c3f80fea3;hp=b4adbbd3eeffdb1e5ee774aa0027cac3d91475e2;hpb=d9926005b1195c8cb4607dd45c21c7ad6c4f4c80;p=github%2Fwallabag%2Fwallabag.git diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php index b4adbbd3..4b480ff1 100644 --- a/src/Wallabag/CoreBundle/Entity/Tag.php +++ b/src/Wallabag/CoreBundle/Entity/Tag.php @@ -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)