X-Git-Url: https://git.rapsys.eu/airbundle/blobdiff_plain/2165a9bd9a68d72ab31f2c4c6f07e276736509da..f338800ff68dbc6a872e9d428c37cb6a6fd1773d:/Entity/User.php?ds=inline diff --git a/Entity/User.php b/Entity/User.php index 387b196..178bcec 100644 --- a/Entity/User.php +++ b/Entity/User.php @@ -1,11 +1,11 @@ + * (c) Raphaël Gertz * - * for the full copyright and license information, please view the license + * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ @@ -14,66 +14,70 @@ namespace Rapsys\AirBundle\Entity; use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\ArrayCollection; +use Rapsys\UserBundle\Entity\Civility; use Rapsys\UserBundle\Entity\User as BaseUser; +/** + * {@inheritdoc} + */ class User extends BaseUser { /** - * @var ?string + * City */ - private ?string $city; + private ?string $city = null; /** - * @var ?string + * Country */ - private ?string $phone; + private ?Country $country = null; /** - * @var Country + * Phone */ - private ?Country $country; + private ?string $phone = null; /** - * @var ?string + * Pseudonym */ - private ?string $pseudonym; + private ?string $pseudonym = null; /** - * @var ?string + * Zipcode */ - private ?string $zipcode; + private ?string $zipcode = null; /** - * @var \Doctrine\Common\Collections\Collection + * Applications collection */ private Collection $applications; /** - * @var \Doctrine\Common\Collections\Collection + * Dances collection */ private Collection $dances; /** - * @var \Doctrine\Common\Collections\Collection + * Locations collection */ private Collection $locations; /** - * @var \Doctrine\Common\Collections\Collection + * Snippets collection */ private Collection $snippets; /** - * @var \Doctrine\Common\Collections\Collection + * Subscribers collection */ private Collection $subscribers; /** - * @var \Doctrine\Common\Collections\Collection + * Subscriptions collection */ private Collection $subscriptions; /** - * @var \Doctrine\Common\Collections\Collection + * Google tokens collection */ private Collection $googleTokens; @@ -81,17 +85,16 @@ class User extends BaseUser { * Constructor * * @param string $mail The user mail - */ - public function __construct(string $mail) { + * @param string $password The user password + * @param ?Civility $civility The user civility + * @param ?string $forename The user forename + * @param ?string $surname The user surname + * @param bool $active The user active + * @param bool $enable The user enable + */ + 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) { //Call parent constructor - parent::__construct($mail); - - //Set defaults - $this->city = null; - $this->country = null; - $this->phone = null; - $this->pseudonym = null; - $this->zipcode = null; + parent::__construct($this->mail, $this->password, $this->civility, $this->forename, $this->surname, $this->active, $this->enable); //Set collections $this->applications = new ArrayCollection(); @@ -347,6 +350,9 @@ class User extends BaseUser { * @return User */ public function addSubscriber(User $subscriber): User { + //Add from owning side + $subscriber->addSubscription($this); + $this->subscribers[] = $subscriber; return $this; @@ -358,6 +364,13 @@ class User extends BaseUser { * @param User $subscriber */ public function removeSubscriber(User $subscriber): bool { + if (!$this->subscriptions->contains($subscriber)) { + return true; + } + + //Remove from owning side + $subscriber->removeSubscription($this); + return $this->subscribers->removeElement($subscriber); } @@ -378,9 +391,6 @@ class User extends BaseUser { * @return User */ public function addSubscription(User $subscription): User { - //Add from owning side - $subscription->addSubscriber($this); - $this->subscriptions[] = $subscription; return $this; @@ -392,13 +402,6 @@ class User extends BaseUser { * @param User $subscription */ public function removeSubscription(User $subscription): bool { - if (!$this->users->contains($user)) { - return true; - } - - //Remove from owning side - $subscription->removeSubscriber($this); - return $this->subscriptions->removeElement($subscription); }