]> Raphaël G. Git Repositories - airbundle/blob - Entity/User.php
Rename rapsysair:calendar2 command to rapsysair:calendar
[airbundle] / Entity / User.php
1 <?php declare(strict_types=1);
2
3 /*
4 * This file is part of the Rapsys AirBundle package.
5 *
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Rapsys\AirBundle\Entity;
13
14 use Doctrine\Common\Collections\Collection;
15 use Doctrine\Common\Collections\ArrayCollection;
16
17 use Rapsys\UserBundle\Entity\Civility;
18 use Rapsys\UserBundle\Entity\User as BaseUser;
19
20 /**
21 * {@inheritdoc}
22 */
23 class User extends BaseUser {
24 /**
25 * City
26 */
27 private ?string $city = null;
28
29 /**
30 * Country
31 */
32 private ?Country $country = null;
33
34 /**
35 * Phone
36 */
37 private ?string $phone = null;
38
39 /**
40 * Pseudonym
41 */
42 private ?string $pseudonym = null;
43
44 /**
45 * Zipcode
46 */
47 private ?string $zipcode = null;
48
49 /**
50 * Applications collection
51 */
52 private Collection $applications;
53
54 /**
55 * Dances collection
56 */
57 private Collection $dances;
58
59 /**
60 * Locations collection
61 */
62 private Collection $locations;
63
64 /**
65 * Snippets collection
66 */
67 private Collection $snippets;
68
69 /**
70 * Subscribers collection
71 */
72 private Collection $subscribers;
73
74 /**
75 * Subscriptions collection
76 */
77 private Collection $subscriptions;
78
79 /**
80 * Google tokens collection
81 */
82 private Collection $googleTokens;
83
84 /**
85 * Constructor
86 *
87 * @param string $mail The user mail
88 * @param string $password The user password
89 * @param ?Civility $civility The user civility
90 * @param ?string $forename The user forename
91 * @param ?string $surname The user surname
92 * @param bool $active The user active
93 * @param bool $enable The user enable
94 */
95 public function __construct(protected string $mail, protected string $password, protected ?Civility $civility = null, protected ?string $forename = null, protected ?string $surname = null, protected bool $active = false, protected bool $enable = true) {
96 //Call parent constructor
97 parent::__construct($this->mail, $this->password, $this->civility, $this->forename, $this->surname, $this->active, $this->enable);
98
99 //Set collections
100 $this->applications = new ArrayCollection();
101 $this->dances = new ArrayCollection();
102 $this->locations = new ArrayCollection();
103 $this->snippets = new ArrayCollection();
104 $this->subscribers = new ArrayCollection();
105 $this->subscriptions = new ArrayCollection();
106 $this->googleTokens = new ArrayCollection();
107 }
108
109 /**
110 * Set city
111 *
112 * @param string $city
113 *
114 * @return User
115 */
116 public function setCity(?string $city): User {
117 $this->city = $city;
118
119 return $this;
120 }
121
122 /**
123 * Get city
124 *
125 * @return string
126 */
127 public function getCity(): ?string {
128 return $this->city;
129 }
130
131 /**
132 * Set country
133 *
134 * @param Country $country
135 *
136 * @return User
137 */
138 public function setCountry(?Country $country): User {
139 $this->country = $country;
140
141 return $this;
142 }
143
144 /**
145 * Get country
146 *
147 * @return Country
148 */
149 public function getCountry(): ?Country {
150 return $this->country;
151 }
152
153 /**
154 * Set phone
155 *
156 * @param string $phone
157 *
158 * @return User
159 */
160 public function setPhone(?string $phone): User {
161 $this->phone = $phone;
162
163 return $this;
164 }
165
166 /**
167 * Get phone
168 *
169 * @return string
170 */
171 public function getPhone(): ?string {
172 return $this->phone;
173 }
174
175 /**
176 * Set pseudonym
177 *
178 * @param string $pseudonym
179 *
180 * @return User
181 */
182 public function setPseudonym(?string $pseudonym): User {
183 $this->pseudonym = $pseudonym;
184
185 return $this;
186 }
187
188 /**
189 * Get pseudonym
190 *
191 * @return string
192 */
193 public function getPseudonym(): ?string {
194 return $this->pseudonym;
195 }
196
197 /**
198 * Set zipcode
199 *
200 * @param string $zipcode
201 *
202 * @return User
203 */
204 public function setZipcode(?string $zipcode): User {
205 $this->zipcode = $zipcode;
206
207 return $this;
208 }
209
210 /**
211 * Get zipcode
212 *
213 * @return string
214 */
215 public function getZipcode(): ?string {
216 return $this->zipcode;
217 }
218
219 /**
220 * Add application
221 *
222 * @param Application $application
223 *
224 * @return User
225 */
226 public function addApplication(Application $application): User {
227 $this->applications[] = $application;
228
229 return $this;
230 }
231
232 /**
233 * Remove application
234 *
235 * @param Application $application
236 */
237 public function removeApplication(Application $application): bool {
238 return $this->applications->removeElement($application);
239 }
240
241 /**
242 * Get applications
243 *
244 * @return \Doctrine\Common\Collections\Collection
245 */
246 public function getApplications(): Collection {
247 return $this->applications;
248 }
249
250 /**
251 * Add dance
252 *
253 * @param Dance $dance
254 *
255 * @return User
256 */
257 public function addDance(Dance $dance): User {
258 $this->dances[] = $dance;
259
260 return $this;
261 }
262
263 /**
264 * Remove dance
265 *
266 * @param Dance $dance
267 *
268 * @return bool
269 */
270 public function removeDance(Dance $dance): bool {
271 return $this->dances->removeElement($dance);
272 }
273
274 /**
275 * Get dances
276 *
277 * @return \Doctrine\Common\Collections\Collection
278 */
279 public function getDances(): Collection {
280 return $this->dances;
281 }
282
283 /**
284 * Add location
285 *
286 * @param Location $location
287 *
288 * @return User
289 */
290 public function addLocation(Location $location): User {
291 $this->locations[] = $location;
292
293 return $this;
294 }
295
296 /**
297 * Remove location
298 *
299 * @param Location $location
300 */
301 public function removeLocation(Location $location): bool {
302 return $this->locations->removeElement($location);
303 }
304
305 /**
306 * Get locations
307 *
308 * @return \Doctrine\Common\Collections\Collection
309 */
310 public function getLocations(): Collection {
311 return $this->locations;
312 }
313
314 /**
315 * Add snippet
316 *
317 * @param Snippet $snippet
318 *
319 * @return User
320 */
321 public function addSnippet(Snippet $snippet): User {
322 $this->snippets[] = $snippet;
323
324 return $this;
325 }
326
327 /**
328 * Remove snippet
329 *
330 * @param Snippet $snippet
331 */
332 public function removeSnippet(Snippet $snippet): bool {
333 return $this->snippets->removeElement($snippet);
334 }
335
336 /**
337 * Get snippets
338 *
339 * @return \Doctrine\Common\Collections\Collection
340 */
341 public function getSnippets(): Collection {
342 return $this->snippets;
343 }
344
345 /**
346 * Add subscriber
347 *
348 * @param User $subscriber
349 *
350 * @return User
351 */
352 public function addSubscriber(User $subscriber): User {
353 //Add from owning side
354 $subscriber->addSubscription($this);
355
356 $this->subscribers[] = $subscriber;
357
358 return $this;
359 }
360
361 /**
362 * Remove subscriber
363 *
364 * @param User $subscriber
365 */
366 public function removeSubscriber(User $subscriber): bool {
367 if (!$this->subscriptions->contains($subscriber)) {
368 return true;
369 }
370
371 //Remove from owning side
372 $subscriber->removeSubscription($this);
373
374 return $this->subscribers->removeElement($subscriber);
375 }
376
377 /**
378 * Get subscribers
379 *
380 * @return \Doctrine\Common\Collections\Collection
381 */
382 public function getSubscribers(): Collection {
383 return $this->subscribers;
384 }
385
386 /**
387 * Add subscription
388 *
389 * @param User $subscription
390 *
391 * @return User
392 */
393 public function addSubscription(User $subscription): User {
394 $this->subscriptions[] = $subscription;
395
396 return $this;
397 }
398
399 /**
400 * Remove subscription
401 *
402 * @param User $subscription
403 */
404 public function removeSubscription(User $subscription): bool {
405 return $this->subscriptions->removeElement($subscription);
406 }
407
408 /**
409 * Get subscriptions
410 *
411 * @return \Doctrine\Common\Collections\Collection
412 */
413 public function getSubscriptions(): Collection {
414 return $this->subscriptions;
415 }
416
417 /**
418 * Add google token
419 *
420 * @param GoogleToken $googleToken
421 *
422 * @return User
423 */
424 public function addGoogleToken(GoogleToken $googleToken): User {
425 $this->googleTokens[] = $googleToken;
426
427 return $this;
428 }
429
430 /**
431 * Remove google token
432 *
433 * @param GoogleToken $googleToken
434 */
435 public function removeGoogleToken(GoogleToken $googleToken): bool {
436 return $this->googleTokens->removeElement($googleToken);
437 }
438
439 /**
440 * Get googleTokens
441 *
442 * @return \Doctrine\Common\Collections\Collection
443 */
444 public function getGoogleTokens(): Collection {
445 return $this->googleTokens;
446 }
447 }