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