]>
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 | { |
092ca707 | 51 | $this->user = $user; |
46bbd8d3 NL |
52 | $this->entries = new ArrayCollection(); |
53 | } | |
9d50517c | 54 | /** |
4346a860 | 55 | * Get id. |
9d50517c | 56 | * |
4346a860 | 57 | * @return int |
9d50517c NL |
58 | */ |
59 | public function getId() | |
60 | { | |
61 | return $this->id; | |
62 | } | |
63 | ||
64 | /** | |
4346a860 JB |
65 | * Set label. |
66 | * | |
67 | * @param string $label | |
9d50517c | 68 | * |
653e8be4 | 69 | * @return Tag |
9d50517c | 70 | */ |
653e8be4 | 71 | public function setLabel($label) |
9d50517c | 72 | { |
653e8be4 | 73 | $this->label = $label; |
9d50517c NL |
74 | |
75 | return $this; | |
76 | } | |
77 | ||
78 | /** | |
4346a860 | 79 | * Get label. |
9d50517c | 80 | * |
7df80cb3 | 81 | * @return string |
9d50517c | 82 | */ |
653e8be4 | 83 | public function getLabel() |
9d50517c | 84 | { |
2691cf04 | 85 | return $this->label; |
9d50517c | 86 | } |
46bbd8d3 NL |
87 | |
88 | public function addEntry(Entry $entry) | |
89 | { | |
90 | $this->entries[] = $entry; | |
91 | } | |
48b67328 NL |
92 | |
93 | /** | |
94 | * @return User | |
95 | */ | |
96 | public function getUser() | |
97 | { | |
98 | return $this->user; | |
99 | } | |
9d50517c | 100 | } |