]>
Commit | Line | Data |
---|---|---|
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="User", inversedBy="tags") | |
46 | */ | |
47 | private $user; | |
48 | ||
49 | public function __construct(User $user) | |
50 | { | |
51 | $this->user = $user; | |
52 | $this->entries = new ArrayCollection(); | |
53 | } | |
54 | /** | |
55 | * Get id. | |
56 | * | |
57 | * @return int | |
58 | */ | |
59 | public function getId() | |
60 | { | |
61 | return $this->id; | |
62 | } | |
63 | ||
64 | /** | |
65 | * Set label. | |
66 | * | |
67 | * @param string $label | |
68 | * | |
69 | * @return Tag | |
70 | */ | |
71 | public function setLabel($label) | |
72 | { | |
73 | $this->label = $label; | |
74 | ||
75 | return $this; | |
76 | } | |
77 | ||
78 | /** | |
79 | * Get label. | |
80 | * | |
81 | * @return string | |
82 | */ | |
83 | public function getLabel() | |
84 | { | |
85 | return $this->label; | |
86 | } | |
87 | ||
88 | public function addEntry(Entry $entry) | |
89 | { | |
90 | $this->entries[] = $entry; | |
91 | } | |
92 | ||
93 | /** | |
94 | * @return User | |
95 | */ | |
96 | public function getUser() | |
97 | { | |
98 | return $this->user; | |
99 | } | |
100 | } |