]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Entity/Tag.php
Merge pull request #1164 from wallabag/v2-remove-username-in-config
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Tag.php
index 963f32b1ef20df88b334a3c6a658c55ea926d97e..9d3c7a32105327cceccadecc0f74711d6d09c3ff 100644 (file)
@@ -3,18 +3,25 @@
 namespace Wallabag\CoreBundle\Entity;
 
 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
  *
- * @ORM\Table(name="tag")
- * @ORM\Entity
+ * @XmlRoot("tag")
+ * @ORM\Table
+ * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
+ * @ExclusionPolicy("all")
  */
 class Tag
 {
     /**
      * @var integer
      *
+     * @Expose
      * @ORM\Column(name="id", type="integer")
      * @ORM\Id
      * @ORM\GeneratedValue(strategy="AUTO")
@@ -24,10 +31,26 @@ class Tag
     /**
      * @var string
      *
+     * @Expose
      * @ORM\Column(name="label", type="text")
      */
     private $label;
 
+    /**
+     * @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
      *
@@ -60,4 +83,17 @@ class Tag
     {
         return $this->label;
     }
+
+    public function addEntry(Entry $entry)
+    {
+        $this->entries[] = $entry;
+    }
+
+    /**
+     * @return User
+     */
+    public function getUser()
+    {
+        return $this->user;
+    }
 }