]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Tag.php
Remove user reference in tag
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Tag.php
index afe9e1b9af22a8d4263d29a9728afa641ca0c894..0689c7b31854fc0dbd58c40ca105d8a1c9c7cc68 100644 (file)
@@ -7,12 +7,13 @@ use JMS\Serializer\Annotation\XmlRoot;
 use JMS\Serializer\Annotation\ExclusionPolicy;
 use JMS\Serializer\Annotation\Expose;
 use Doctrine\Common\Collections\ArrayCollection;
+use Gedmo\Mapping\Annotation as Gedmo;
 
 /**
  * Tag.
  *
  * @XmlRoot("tag")
- * @ORM\Table
+ * @ORM\Table(name="`tag`")
  * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
  * @ExclusionPolicy("all")
  */
@@ -37,20 +38,27 @@ class Tag
     private $label;
 
     /**
-     * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
+     * @Expose
+     * @Gedmo\Slug(fields={"label"})
+     * @ORM\Column(length=128, unique=true)
      */
-    private $entries;
+    private $slug;
 
     /**
-     * @ORM\ManyToOne(targetEntity="User", inversedBy="tags")
+     * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
      */
-    private $user;
+    private $entries;
 
-    public function __construct(User $user)
+    public function __construct()
     {
-        $this->user    = $user;
         $this->entries = new ArrayCollection();
     }
+
+    public function __toString()
+    {
+        return $this->label;
+    }
+
     /**
      * Get id.
      *
@@ -85,16 +93,18 @@ class Tag
         return $this->label;
     }
 
+    public function getSlug()
+    {
+        return $this->slug;
+    }
+
     public function addEntry(Entry $entry)
     {
         $this->entries[] = $entry;
     }
 
-    /**
-     * @return User
-     */
-    public function getUser()
+    public function hasEntry($entry)
     {
-        return $this->user;
+        return $this->entries->contains($entry);
     }
 }