]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Entity/Tag.php
Merge pull request #1436 from wallabag/v2-register
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Entity / Tag.php
1 <?php
2
3 namespace Wallabag\CoreBundle\Entity;
4
5 use Doctrine\ORM\Mapping as ORM;
6 use JMS\Serializer\Annotation\XmlRoot;
7 use JMS\Serializer\Annotation\ExclusionPolicy;
8 use JMS\Serializer\Annotation\Expose;
9 use Doctrine\Common\Collections\ArrayCollection;
10
11 /**
12 * Tag.
13 *
14 * @XmlRoot("tag")
15 * @ORM\Table
16 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
17 * @ExclusionPolicy("all")
18 */
19 class Tag
20 {
21 /**
22 * @var int
23 *
24 * @Expose
25 * @ORM\Column(name="id", type="integer")
26 * @ORM\Id
27 * @ORM\GeneratedValue(strategy="AUTO")
28 */
29 private $id;
30
31 /**
32 * @var string
33 *
34 * @Expose
35 * @ORM\Column(name="label", type="text")
36 */
37 private $label;
38
39 /**
40 * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"})
41 */
42 private $entries;
43
44 /**
45 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="tags")
46 */
47 private $user;
48
49 public function __construct(\Wallabag\UserBundle\Entity\User $user)
50 {
51 $this->user = $user;
52 $this->entries = new ArrayCollection();
53 }
54
55 public function __toString()
56 {
57 return $this->label;
58 }
59
60 /**
61 * Get id.
62 *
63 * @return int
64 */
65 public function getId()
66 {
67 return $this->id;
68 }
69
70 /**
71 * Set label.
72 *
73 * @param string $label
74 *
75 * @return Tag
76 */
77 public function setLabel($label)
78 {
79 $this->label = $label;
80
81 return $this;
82 }
83
84 /**
85 * Get label.
86 *
87 * @return string
88 */
89 public function getLabel()
90 {
91 return $this->label;
92 }
93
94 public function addEntry(Entry $entry)
95 {
96 $this->entries[] = $entry;
97 }
98
99 public function hasEntry($entry)
100 {
101 return $this->entries->contains($entry);
102 }
103
104 /**
105 * @return User
106 */
107 public function getUser()
108 {
109 return $this->user;
110 }
111 }