diff options
author | Thomas Citharel <tcit@tcit.fr> | 2017-01-31 21:13:33 +0100 |
---|---|---|
committer | Thomas Citharel <tcit@tcit.fr> | 2017-06-23 09:26:41 +0200 |
commit | 2041810adbc6e663e4520337805c0003c77762e2 (patch) | |
tree | 1715a1e57a0275efe0970807c65f424def897034 /src/Wallabag/GroupBundle/Entity/UserGroup.php | |
parent | b115623e2c536bcfd59760347f22b4d70e1d0661 (diff) | |
download | wallabag-2041810adbc6e663e4520337805c0003c77762e2.tar.gz wallabag-2041810adbc6e663e4520337805c0003c77762e2.tar.zst wallabag-2041810adbc6e663e4520337805c0003c77762e2.zip |
WIP
Diffstat (limited to 'src/Wallabag/GroupBundle/Entity/UserGroup.php')
-rw-r--r-- | src/Wallabag/GroupBundle/Entity/UserGroup.php | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/src/Wallabag/GroupBundle/Entity/UserGroup.php b/src/Wallabag/GroupBundle/Entity/UserGroup.php new file mode 100644 index 00000000..22d1400a --- /dev/null +++ b/src/Wallabag/GroupBundle/Entity/UserGroup.php | |||
@@ -0,0 +1,126 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\GroupBundle\Entity; | ||
4 | |||
5 | use Doctrine\ORM\Mapping as ORM; | ||
6 | use FOS\UserBundle\Model\GroupInterface; | ||
7 | use Symfony\Component\Validator\Constraints as Assert; | ||
8 | use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; | ||
9 | use Wallabag\UserBundle\Entity\User; | ||
10 | |||
11 | /** | ||
12 | * @ORM\Entity(repositoryClass="Wallabag\GroupBundle\Repository\UserGroupRepository") | ||
13 | * @UniqueEntity({"user_id", "group_id"}) | ||
14 | * @ORM\Table(name="fos_user_group") | ||
15 | */ | ||
16 | class UserGroup | ||
17 | { | ||
18 | /** | ||
19 | * @ORM\Column(name="id", type="integer") | ||
20 | * @ORM\Id | ||
21 | * @ORM\GeneratedValue(strategy="AUTO") | ||
22 | */ | ||
23 | private $id; | ||
24 | |||
25 | /** | ||
26 | * @ORM\Column(name="role", type="integer") | ||
27 | */ | ||
28 | private $role; | ||
29 | |||
30 | /** | ||
31 | * @ORM\ManyToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="userGroups") | ||
32 | * @ORM\JoinColumn(name="user_id", referencedColumnName="id") | ||
33 | */ | ||
34 | private $user; | ||
35 | |||
36 | /** | ||
37 | * @ORM\ManyToOne(targetEntity="Wallabag\GroupBundle\Entity\Group", inversedBy="users") | ||
38 | * @ORM\JoinColumn(name="group_id", referencedColumnName="id") | ||
39 | */ | ||
40 | private $group; | ||
41 | |||
42 | /** | ||
43 | * @ORM\Column(name="accepted", type="boolean", options={"default" : false}) | ||
44 | */ | ||
45 | private $accepted; | ||
46 | |||
47 | /** | ||
48 | * @ORM\OneToOne(targetEntity="Wallabag\GroupBundle\Entity\Invitation", inversedBy="userGroup", cascade={"persist", "remove"}) | ||
49 | * @ORM\JoinColumn(name="invitation", referencedColumnName="code") | ||
50 | */ | ||
51 | protected $invitation; | ||
52 | |||
53 | /** | ||
54 | * UserGroup constructor. | ||
55 | * @param User $user | ||
56 | * @param Group $group | ||
57 | * @param $role | ||
58 | */ | ||
59 | public function __construct(User $user, Group $group, $role, $request = false) | ||
60 | { | ||
61 | $this->user = $user; | ||
62 | $this->group = $group; | ||
63 | $this->role = $role; | ||
64 | $this->accepted = $request; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * @return Group | ||
69 | */ | ||
70 | public function getGroup() | ||
71 | { | ||
72 | return $this->group; | ||
73 | } | ||
74 | |||
75 | /** | ||
76 | * @return int | ||
77 | */ | ||
78 | public function getRole() | ||
79 | { | ||
80 | return $this->role; | ||
81 | } | ||
82 | |||
83 | /** | ||
84 | * @return User | ||
85 | */ | ||
86 | public function getUser() | ||
87 | { | ||
88 | return $this->user; | ||
89 | } | ||
90 | |||
91 | /** | ||
92 | * @param int $role | ||
93 | * @return UserGroup | ||
94 | */ | ||
95 | public function setRole($role) | ||
96 | { | ||
97 | $this->role = $role; | ||
98 | return $this; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * @param bool $accepted | ||
103 | */ | ||
104 | public function setAccepted($accepted) | ||
105 | { | ||
106 | $this->accepted = $accepted; | ||
107 | } | ||
108 | |||
109 | /** | ||
110 | * @return bool | ||
111 | */ | ||
112 | public function isAccepted() | ||
113 | { | ||
114 | return $this->accepted; | ||
115 | } | ||
116 | |||
117 | public function setInvitation($invitation) | ||
118 | { | ||
119 | $this->invitation = $invitation; | ||
120 | } | ||
121 | |||
122 | public function getInvitation() | ||
123 | { | ||
124 | return $this->invitation; | ||
125 | } | ||
126 | } | ||