]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/GroupBundle/Entity/UserGroup.php
Fixed typos
[github/wallabag/wallabag.git] / src / Wallabag / GroupBundle / Entity / UserGroup.php
CommitLineData
2041810a
TC
1<?php
2
3namespace Wallabag\GroupBundle\Entity;
4
5use Doctrine\ORM\Mapping as ORM;
2041810a
TC
6use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
7use Wallabag\UserBundle\Entity\User;
8
9/**
10 * @ORM\Entity(repositoryClass="Wallabag\GroupBundle\Repository\UserGroupRepository")
11 * @UniqueEntity({"user_id", "group_id"})
2585953e 12 * @ORM\Table(name="user_group")
2041810a
TC
13 */
14class UserGroup
15{
16 /**
17 * @ORM\Column(name="id", type="integer")
18 * @ORM\Id
19 * @ORM\GeneratedValue(strategy="AUTO")
20 */
21 private $id;
22
23 /**
24 * @ORM\Column(name="role", type="integer")
25 */
26 private $role;
27
28 /**
29 * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="userGroups")
30 * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
31 */
32 private $user;
33
34 /**
35 * @ORM\ManyToOne(targetEntity="Wallabag\GroupBundle\Entity\Group", inversedBy="users")
36 * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
37 */
38 private $group;
39
40 /**
41 * @ORM\Column(name="accepted", type="boolean", options={"default" : false})
42 */
43 private $accepted;
44
45 /**
46 * @ORM\OneToOne(targetEntity="Wallabag\GroupBundle\Entity\Invitation", inversedBy="userGroup", cascade={"persist", "remove"})
47 * @ORM\JoinColumn(name="invitation", referencedColumnName="code")
48 */
49 protected $invitation;
50
51 /**
52 * UserGroup constructor.
2585953e
NL
53 *
54 * @param User $user
2041810a
TC
55 * @param Group $group
56 * @param $role
57 */
58 public function __construct(User $user, Group $group, $role, $request = false)
59 {
60 $this->user = $user;
61 $this->group = $group;
62 $this->role = $role;
63 $this->accepted = $request;
64 }
65
66 /**
67 * @return Group
68 */
69 public function getGroup()
70 {
71 return $this->group;
72 }
73
74 /**
75 * @return int
76 */
77 public function getRole()
78 {
79 return $this->role;
80 }
81
82 /**
83 * @return User
84 */
85 public function getUser()
86 {
87 return $this->user;
88 }
89
90 /**
91 * @param int $role
2585953e 92 *
2041810a
TC
93 * @return UserGroup
94 */
95 public function setRole($role)
96 {
97 $this->role = $role;
2585953e 98
2041810a
TC
99 return $this;
100 }
101
102 /**
103 * @param bool $accepted
104 */
105 public function setAccepted($accepted)
106 {
107 $this->accepted = $accepted;
108 }
109
110 /**
111 * @return bool
112 */
113 public function isAccepted()
114 {
115 return $this->accepted;
116 }
117
118 public function setInvitation($invitation)
119 {
120 $this->invitation = $invitation;
121 }
122
123 public function getInvitation()
124 {
125 return $this->invitation;
126 }
127}