use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
+use Rapsys\UserBundle\Entity\Civility;
use Rapsys\UserBundle\Entity\User as BaseUser;
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);
+ parent::__construct($this->mail, $this->password, $this->civility, $this->forename, $this->surname, $this->active, $this->enable);
//Set defaults
$this->city = null;
* @return User
*/
public function addSubscriber(User $subscriber): User {
+ //Add from owning side
+ $subscriber->addSubscription($this);
+
$this->subscribers[] = $subscriber;
return $this;
* @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);
}
* @return User
*/
public function addSubscription(User $subscription): User {
- //Add from owning side
- $subscription->addSubscriber($this);
-
$this->subscriptions[] = $subscription;
return $this;
* @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);
}