]>
Commit | Line | Data |
---|---|---|
9d50517c NL |
1 | <?php |
2 | ||
ad4d1caa | 3 | namespace Wallabag\CoreBundle\Entity; |
9d50517c NL |
4 | |
5 | use Doctrine\ORM\Mapping as ORM; | |
6d37a7e6 | 6 | use JMS\Serializer\Annotation\XmlRoot; |
0a018fe0 NL |
7 | use JMS\Serializer\Annotation\ExclusionPolicy; |
8 | use JMS\Serializer\Annotation\Expose; | |
46bbd8d3 | 9 | use Doctrine\Common\Collections\ArrayCollection; |
9d50517c NL |
10 | |
11 | /** | |
4346a860 | 12 | * Tag. |
9d50517c | 13 | * |
6d37a7e6 | 14 | * @XmlRoot("tag") |
164bd801 | 15 | * @ORM\Table |
6d37a7e6 | 16 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository") |
0a018fe0 | 17 | * @ExclusionPolicy("all") |
9d50517c | 18 | */ |
653e8be4 | 19 | class Tag |
9d50517c NL |
20 | { |
21 | /** | |
4346a860 | 22 | * @var int |
9d50517c | 23 | * |
0a018fe0 | 24 | * @Expose |
653e8be4 | 25 | * @ORM\Column(name="id", type="integer") |
9d50517c | 26 | * @ORM\Id |
653e8be4 | 27 | * @ORM\GeneratedValue(strategy="AUTO") |
9d50517c NL |
28 | */ |
29 | private $id; | |
30 | ||
31 | /** | |
32 | * @var string | |
33 | * | |
0a018fe0 | 34 | * @Expose |
653e8be4 | 35 | * @ORM\Column(name="label", type="text") |
9d50517c | 36 | */ |
653e8be4 | 37 | private $label; |
9d50517c | 38 | |
0a018fe0 | 39 | /** |
46bbd8d3 | 40 | * @ORM\ManyToMany(targetEntity="Entry", mappedBy="tags", cascade={"persist"}) |
0a018fe0 NL |
41 | */ |
42 | private $entries; | |
43 | ||
092ca707 NL |
44 | /** |
45 | * @ORM\ManyToOne(targetEntity="User", inversedBy="tags") | |
46 | */ | |
47 | private $user; | |
48 | ||
49 | public function __construct(User $user) | |
46bbd8d3 | 50 | { |
8ce32af6 | 51 | $this->user = $user; |
46bbd8d3 NL |
52 | $this->entries = new ArrayCollection(); |
53 | } | |
82d6d9cb JB |
54 | |
55 | public function __toString() | |
56 | { | |
57 | return $this->label; | |
58 | } | |
59 | ||
9d50517c | 60 | /** |
4346a860 | 61 | * Get id. |
9d50517c | 62 | * |
4346a860 | 63 | * @return int |
9d50517c NL |
64 | */ |
65 | public function getId() | |
66 | { | |
67 | return $this->id; | |
68 | } | |
69 | ||
70 | /** | |
4346a860 JB |
71 | * Set label. |
72 | * | |
73 | * @param string $label | |
9d50517c | 74 | * |
653e8be4 | 75 | * @return Tag |
9d50517c | 76 | */ |
653e8be4 | 77 | public function setLabel($label) |
9d50517c | 78 | { |
653e8be4 | 79 | $this->label = $label; |
9d50517c NL |
80 | |
81 | return $this; | |
82 | } | |
83 | ||
84 | /** | |
4346a860 | 85 | * Get label. |
9d50517c | 86 | * |
7df80cb3 | 87 | * @return string |
9d50517c | 88 | */ |
653e8be4 | 89 | public function getLabel() |
9d50517c | 90 | { |
2691cf04 | 91 | return $this->label; |
9d50517c | 92 | } |
46bbd8d3 NL |
93 | |
94 | public function addEntry(Entry $entry) | |
95 | { | |
96 | $this->entries[] = $entry; | |
97 | } | |
48b67328 NL |
98 | |
99 | /** | |
100 | * @return User | |
101 | */ | |
102 | public function getUser() | |
103 | { | |
104 | return $this->user; | |
105 | } | |
9d50517c | 106 | } |