]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Entity/Tag.php
add relation between user and tags, tests are broken
[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
11 /**
12 * Tag
13 *
14 * @XmlRoot("tag")
15 * @ORM\Table(name="tag")
16 * @ORM\Entity(repositoryClass="Wallabag\CoreBundle\Repository\TagRepository")
17 * @ExclusionPolicy("all")
18 */
19 class Tag
20 {
21 /**
22 * @var integer
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 integer
58 */
59 public function getId()
60 {
61 return $this->id;
62 }
63
64 /**
65 * Set label
66 *
67 * @param string $label
68 * @return Tag
69 */
70 public function setLabel($label)
71 {
72 $this->label = $label;
73
74 return $this;
75 }
76
77 /**
78 * Get label
79 *
80 * @return string
81 */
82 public function getLabel()
83 {
84 return $this->label;
85 }
86
87 public function addEntry(Entry $entry)
88 {
89 $this->entries[] = $entry;
90 }
91 }