aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/FederationBundle/Entity/Account.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/FederationBundle/Entity/Account.php')
-rw-r--r--src/Wallabag/FederationBundle/Entity/Account.php307
1 files changed, 307 insertions, 0 deletions
diff --git a/src/Wallabag/FederationBundle/Entity/Account.php b/src/Wallabag/FederationBundle/Entity/Account.php
new file mode 100644
index 00000000..c44050d9
--- /dev/null
+++ b/src/Wallabag/FederationBundle/Entity/Account.php
@@ -0,0 +1,307 @@
1<?php
2
3namespace Wallabag\FederationBundle\Entity;
4
5use Doctrine\Common\Collections\ArrayCollection;
6use Doctrine\Common\Collections\Collection;
7use Doctrine\ORM\Mapping as ORM;
8use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
9use Symfony\Component\Validator\Constraints as Assert;
10use Wallabag\CoreBundle\Entity\Entry;
11use Wallabag\UserBundle\Entity\User;
12
13/**
14 * Account.
15 *
16 * @ORM\Entity(repositoryClass="Wallabag\FederationBundle\Repository\AccountRepository")
17 * @UniqueEntity(fields={"username", "server"}).
18 * @ORM\Table(name="`account`")
19 */
20class Account
21{
22 /**
23 * @var int
24 *
25 * @ORM\Column(name="id", type="integer")
26 * @ORM\Id
27 * @ORM\GeneratedValue(strategy="AUTO")
28 *
29 */
30 private $id;
31
32 /**
33 * @var string
34 *
35 * @ORM\Column(name="username", type="string")
36 */
37 private $username;
38
39 /**
40 * @var Instance
41 *
42 * @ORM\ManyToOne(targetEntity="Wallabag\FederationBundle\Entity\Instance", inversedBy="users")
43 */
44 private $server;
45
46 /**
47 * @var User
48 *
49 * @ORM\OneToOne(targetEntity="Wallabag\UserBundle\Entity\User", inversedBy="account")
50 * @ORM\JoinColumn(nullable=true)
51 */
52 private $user;
53
54 /**
55 * @var ArrayCollection
56 *
57 * @ORM\ManyToMany(targetEntity="Wallabag\FederationBundle\Entity\Account", mappedBy="following")
58 */
59 private $followers;
60
61 /**
62 * @var ArrayCollection
63 *
64 * @ORM\ManyToMany(targetEntity="Wallabag\FederationBundle\Entity\Account", inversedBy="followers")
65 * @ORM\JoinTable(name="follow",
66 * joinColumns={@ORM\JoinColumn(name="account_id", referencedColumnName="id")},
67 * inverseJoinColumns={@ORM\JoinColumn(name="follow_account_id", referencedColumnName="id")}
68 * )
69 */
70 private $following;
71
72 /**
73 * @var string
74 *
75 * @ORM\Column(type="string", nullable=true)
76 *
77 * @Assert\File(mimeTypes={ "image/gif", "image/jpeg", "image/svg+xml", "image/webp", "image/png" })
78 */
79 private $avatar;
80
81 /**
82 * @var string
83 *
84 * @ORM\Column(type="string", nullable=true)
85 *
86 * @Assert\File(mimeTypes={ "image/gif", "image/jpeg", "image/svg+xml", "image/webp", "image/png" })
87 */
88 private $banner;
89
90 /**
91 * @var string
92 *
93 * @ORM\Column(type="text", nullable=true)
94 */
95 private $description;
96
97 /**
98 * Account constructor.
99 */
100 public function __construct()
101 {
102 $this->followers = new ArrayCollection();
103 $this->following = new ArrayCollection();
104 $this->liked = new ArrayCollection();
105 }
106
107 /**
108 * @return int
109 */
110 public function getId()
111 {
112 return $this->id;
113 }
114
115 /**
116 * @return string
117 */
118 public function getUsername()
119 {
120 return $this->username;
121 }
122
123 /**
124 * @param string $username
125 * @return Account
126 */
127 public function setUsername($username)
128 {
129 $this->username = $username;
130 return $this;
131 }
132
133 /**
134 * @return string
135 */
136 public function getServer()
137 {
138 return $this->server;
139 }
140
141 /**
142 * @param string $server
143 * @return Account
144 */
145 public function setServer($server)
146 {
147 $this->server = $server;
148 return $this;
149 }
150
151 /**
152 * @return User
153 */
154 public function getUser()
155 {
156 return $this->user;
157 }
158
159 /**
160 * @param User $user
161 * @return Account
162 */
163 public function setUser(User $user)
164 {
165 $this->user = $user;
166 return $this;
167 }
168
169 /**
170 * @return Collection
171 */
172 public function getFollowers()
173 {
174 return $this->followers;
175 }
176
177 /**
178 * @param Collection $followers
179 * @return Account
180 */
181 public function setFollowers($followers)
182 {
183 $this->followers = $followers;
184 return $this;
185 }
186
187 /**
188 * @param Account $account
189 * @return Account
190 */
191 public function addFollower(Account $account)
192 {
193 $this->followers->add($account);
194 return $this;
195 }
196
197 /**
198 * @return Collection
199 */
200 public function getFollowing()
201 {
202 return $this->following;
203 }
204
205 /**
206 * @param Collection $following
207 * @return Account
208 */
209 public function setFollowing(Collection $following)
210 {
211 $this->following = $following;
212 return $this;
213 }
214
215 /**
216 * @param Account $account
217 * @return Account
218 */
219 public function addFollowing(Account $account)
220 {
221 $this->following->add($account);
222 return $this;
223 }
224
225 /**
226 * @return Collection
227 */
228 public function getLiked()
229 {
230 return $this->liked;
231 }
232
233 /**
234 * @param Collection $liked
235 * @return Account
236 */
237 public function setLiked(Collection $liked)
238 {
239 $this->liked = $liked;
240 return $this;
241 }
242
243 /**
244 * @param Entry $entry
245 * @return Account
246 */
247 public function addLiked(Entry $entry)
248 {
249 $this->liked->add($entry);
250 return $this;
251 }
252
253 /**
254 * @return string
255 */
256 public function getAvatar()
257 {
258 return $this->avatar;
259 }
260
261 /**
262 * @param string $avatar
263 * @return Account
264 */
265 public function setAvatar($avatar)
266 {
267 $this->avatar = $avatar;
268 return $this;
269 }
270
271 /**
272 * @return string
273 */
274 public function getBanner()
275 {
276 return $this->banner;
277 }
278
279 /**
280 * @param string $banner
281 * @return Account
282 */
283 public function setBanner($banner)
284 {
285 $this->banner = $banner;
286 return $this;
287 }
288
289 /**
290 * @return string
291 */
292 public function getDescription()
293 {
294 return $this->description;
295 }
296
297 /**
298 * @param string $description
299 * @return Account
300 */
301 public function setDescription($description)
302 {
303 $this->description = $description;
304 return $this;
305 }
306
307}