]>
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 | /** | |
653e8be4 | 12 | * Tag |
9d50517c | 13 | * |
6d37a7e6 | 14 | * @XmlRoot("tag") |
653e8be4 | 15 | * @ORM\Table(name="tag") |
6d37a7e6 | 16 | * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository") |
0a018fe0 | 17 | * @ExclusionPolicy("all") |
9d50517c | 18 | */ |
653e8be4 | 19 | class Tag |
9d50517c NL |
20 | { |
21 | /** | |
22 | * @var integer | |
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 NL |
54 | /** |
55 | * Get id | |
56 | * | |
7df80cb3 | 57 | * @return integer |
9d50517c NL |
58 | */ |
59 | public function getId() | |
60 | { | |
61 | return $this->id; | |
62 | } | |
63 | ||
64 | /** | |
653e8be4 | 65 | * Set label |
9d50517c | 66 | * |
653e8be4 NL |
67 | * @param string $label |
68 | * @return Tag | |
9d50517c | 69 | */ |
653e8be4 | 70 | public function setLabel($label) |
9d50517c | 71 | { |
653e8be4 | 72 | $this->label = $label; |
9d50517c NL |
73 | |
74 | return $this; | |
75 | } | |
76 | ||
77 | /** | |
653e8be4 | 78 | * Get label |
9d50517c | 79 | * |
7df80cb3 | 80 | * @return string |
9d50517c | 81 | */ |
653e8be4 | 82 | public function getLabel() |
9d50517c | 83 | { |
2691cf04 | 84 | return $this->label; |
9d50517c | 85 | } |
46bbd8d3 NL |
86 | |
87 | public function addEntry(Entry $entry) | |
88 | { | |
89 | $this->entries[] = $entry; | |
90 | } | |
48b67328 NL |
91 | |
92 | /** | |
93 | * @return User | |
94 | */ | |
95 | public function getUser() | |
96 | { | |
97 | return $this->user; | |
98 | } | |
9d50517c | 99 | } |