1 <?php
declare(strict_types
=1);
4 * This file is part of the Rapsys AirBundle package.
6 * (c) Raphaël Gertz <symfony@rapsys.eu>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Rapsys\AirBundle\Entity
;
14 use Doctrine\Common\Collections\Collection
;
15 use Doctrine\Common\Collections\ArrayCollection
;
17 use Rapsys\UserBundle\Entity\Civility
;
18 use Rapsys\UserBundle\Entity\User
as BaseUser
;
23 class User
extends BaseUser
{
27 private ?string $city = null;
32 private ?Country
$country = null;
37 private ?string $phone = null;
42 private ?string $pseudonym = null;
47 private ?string $zipcode = null;
50 * Applications collection
52 private Collection
$applications;
57 private Collection
$dances;
60 * Locations collection
62 private Collection
$locations;
67 private Collection
$snippets;
70 * Subscribers collection
72 private Collection
$subscribers;
75 * Subscriptions collection
77 private Collection
$subscriptions;
80 * Google tokens collection
82 private Collection
$googleTokens;
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
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
);
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();
112 * @param string $city
116 public function setCity(?string $city): User
{
127 public function getCity(): ?string {
134 * @param Country $country
138 public function setCountry(?Country
$country): User
{
139 $this->country
= $country;
149 public function getCountry(): ?Country
{
150 return $this->country
;
156 * @param string $phone
160 public function setPhone(?string $phone): User
{
161 $this->phone
= $phone;
171 public function getPhone(): ?string {
178 * @param string $pseudonym
182 public function setPseudonym(?string $pseudonym): User
{
183 $this->pseudonym
= $pseudonym;
193 public function getPseudonym(): ?string {
194 return $this->pseudonym
;
200 * @param string $zipcode
204 public function setZipcode(?string $zipcode): User
{
205 $this->zipcode
= $zipcode;
215 public function getZipcode(): ?string {
216 return $this->zipcode
;
222 * @param Application $application
226 public function addApplication(Application
$application): User
{
227 $this->applications
[] = $application;
235 * @param Application $application
237 public function removeApplication(Application
$application): bool {
238 return $this->applications
->removeElement($application);
244 * @return \Doctrine\Common\Collections\Collection
246 public function getApplications(): Collection
{
247 return $this->applications
;
253 * @param Dance $dance
257 public function addDance(Dance
$dance): User
{
258 $this->dances
[] = $dance;
266 * @param Dance $dance
270 public function removeDance(Dance
$dance): bool {
271 return $this->dances
->removeElement($dance);
277 * @return \Doctrine\Common\Collections\Collection
279 public function getDances(): Collection
{
280 return $this->dances
;
286 * @param Location $location
290 public function addLocation(Location
$location): User
{
291 $this->locations
[] = $location;
299 * @param Location $location
301 public function removeLocation(Location
$location): bool {
302 return $this->locations
->removeElement($location);
308 * @return \Doctrine\Common\Collections\Collection
310 public function getLocations(): Collection
{
311 return $this->locations
;
317 * @param Snippet $snippet
321 public function addSnippet(Snippet
$snippet): User
{
322 $this->snippets
[] = $snippet;
330 * @param Snippet $snippet
332 public function removeSnippet(Snippet
$snippet): bool {
333 return $this->snippets
->removeElement($snippet);
339 * @return \Doctrine\Common\Collections\Collection
341 public function getSnippets(): Collection
{
342 return $this->snippets
;
348 * @param User $subscriber
352 public function addSubscriber(User
$subscriber): User
{
353 //Add from owning side
354 $subscriber->addSubscription($this);
356 $this->subscribers
[] = $subscriber;
364 * @param User $subscriber
366 public function removeSubscriber(User
$subscriber): bool {
367 if (!$this->subscriptions
->contains($subscriber)) {
371 //Remove from owning side
372 $subscriber->removeSubscription($this);
374 return $this->subscribers
->removeElement($subscriber);
380 * @return \Doctrine\Common\Collections\Collection
382 public function getSubscribers(): Collection
{
383 return $this->subscribers
;
389 * @param User $subscription
393 public function addSubscription(User
$subscription): User
{
394 $this->subscriptions
[] = $subscription;
400 * Remove subscription
402 * @param User $subscription
404 public function removeSubscription(User
$subscription): bool {
405 return $this->subscriptions
->removeElement($subscription);
411 * @return \Doctrine\Common\Collections\Collection
413 public function getSubscriptions(): Collection
{
414 return $this->subscriptions
;
420 * @param GoogleToken $googleToken
424 public function addGoogleToken(GoogleToken
$googleToken): User
{
425 $this->googleTokens
[] = $googleToken;
431 * Remove google token
433 * @param GoogleToken $googleToken
435 public function removeGoogleToken(GoogleToken
$googleToken): bool {
436 return $this->googleTokens
->removeElement($googleToken);
442 * @return \Doctrine\Common\Collections\Collection
444 public function getGoogleTokens(): Collection
{
445 return $this->googleTokens
;