aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Entity/Tag.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Entity/Tag.php')
-rw-r--r--src/Wallabag/CoreBundle/Entity/Tag.php40
1 files changed, 38 insertions, 2 deletions
diff --git a/src/Wallabag/CoreBundle/Entity/Tag.php b/src/Wallabag/CoreBundle/Entity/Tag.php
index 31017563..9ae5867c 100644
--- a/src/Wallabag/CoreBundle/Entity/Tag.php
+++ b/src/Wallabag/CoreBundle/Entity/Tag.php
@@ -3,18 +3,25 @@
3namespace Wallabag\CoreBundle\Entity; 3namespace Wallabag\CoreBundle\Entity;
4 4
5use Doctrine\ORM\Mapping as ORM; 5use Doctrine\ORM\Mapping as ORM;
6use JMS\Serializer\Annotation\XmlRoot;
7use JMS\Serializer\Annotation\ExclusionPolicy;
8use JMS\Serializer\Annotation\Expose;
9use Doctrine\Common\Collections\ArrayCollection;
6 10
7/** 11/**
8 * Tag 12 * Tag
9 * 13 *
14 * @XmlRoot("tag")
10 * @ORM\Table(name="tag") 15 * @ORM\Table(name="tag")
11 * @ORM\Entity 16 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
17 * @ExclusionPolicy("all")
12 */ 18 */
13class Tag 19class Tag
14{ 20{
15 /** 21 /**
16 * @var integer 22 * @var integer
17 * 23 *
24 * @Expose
18 * @ORM\Column(name="id", type="integer") 25 * @ORM\Column(name="id", type="integer")
19 * @ORM\Id 26 * @ORM\Id
20 * @ORM\GeneratedValue(strategy="AUTO") 27 * @ORM\GeneratedValue(strategy="AUTO")
@@ -24,11 +31,27 @@ class Tag
24 /** 31 /**
25 * @var string 32 * @var string
26 * 33 *
34 * @Expose
27 * @ORM\Column(name="label", type="text") 35 * @ORM\Column(name="label", type="text")
28 */ 36 */
29 private $label; 37 private $label;
30 38
31 /** 39 /**
40 * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
41 */
42 private $entries;
43
44 /**
45 * @ORM\ManyToOne(targetEntity="User", inversedBy="tags")
46 */
47 private $user;
48
49 public function __construct(User $user)
50 {
51 $this->user = $user;
52 $this->entries = new ArrayCollection();
53 }
54 /**
32 * Get id 55 * Get id
33 * 56 *
34 * @return integer 57 * @return integer
@@ -58,6 +81,19 @@ class Tag
58 */ 81 */
59 public function getLabel() 82 public function getLabel()
60 { 83 {
61 return $this->value; 84 return $this->label;
85 }
86
87 public function addEntry(Entry $entry)
88 {
89 $this->entries[] = $entry;
90 }
91
92 /**
93 * @return User
94 */
95 public function getUser()
96 {
97 return $this->user;
62 } 98 }
63} 99}