<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
use Doctrine\ORM\Mapping\UniqueConstraint;
/**
* @ORM\Entity(repositoryClass="App\Repository\BFUserRepository")
* @UniqueEntity(
* fields="email",
* message="Email déjà utilisé"
* )
*/
class BFUser implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=180, unique=true)
*/
private $email;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @var string The hashed password
* @ORM\Column(type="string")
*/
private $password;
private $plainPassword;
/**
* @ORM\OneToOne(targetEntity="App\Entity\BFDescriptionUser", inversedBy="bfuser", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=false)
*/
private $description;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $resettoken;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFFestival", mappedBy="owner")
*/
private $ownedfestivals;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\BFFestival", mappedBy="administrators")
*/
private $administratorfestivals;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFSubscription", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
*/
private $subscriptions;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $creationdate;
/**
* @ORM\OneToOne(targetEntity="App\Entity\BFInscriptionUser", mappedBy="user")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $inscriptionuser;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFChallenge", mappedBy="owner")
*/
private $ownedChallenges;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\BFChallenge", mappedBy="administrators")
*/
private $adminChallenges;
/**
* @ORM\OneToMany(targetEntity="App\Entity\BFPaymentIntentEdition", mappedBy="user")
* @ORM\OrderBy({"id" = "DESC"})
*/
private $bFPaymentIntentEditions;
public function __construct()
{
$this->description = new BFDescriptionUser();
$this->ownedfestivals = new ArrayCollection();
$this->administratorfestivals = new ArrayCollection();
$this->subscriptions = new ArrayCollection();
$this->creationdate = new \DateTime('now');
$this->ownedChallenges = new ArrayCollection();
$this->adminChallenges = new ArrayCollection();
$this->bFPaymentIntentEditions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
/**
* A visual identifier that represents this user.
*
* @see UserInterface
*/
public function getUsername(): string
{
return (string) $this->email;
}
/**
* @see UserInterface
*/
public function getRoles(): array
{
$roles = $this->roles;
// guarantee every user at least has ROLE_USER
$roles[] = 'ROLE_USER';
return array_unique($roles);
}
public function setRoles(array $roles): self
{
$this->roles = $roles;
return $this;
}
public function getPlainPassword()
{
return $this->plainPassword;
}
public function setPlainPassword($password)
{
$this->plainPassword = $password;
}
/**
* @see UserInterface
*/
public function getPassword(): string
{
return (string) $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
/**
* @see UserInterface
*/
public function getSalt()
{
// not needed when using the "bcrypt" algorithm in security.yaml
}
/**
* @see UserInterface
*/
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
// $this->plainPassword = null;
}
public function getDescription(): ?BFDescriptionUser
{
return $this->description;
}
public function setDescription(BFDescriptionUser $description): self
{
$this->description = $description;
return $this;
}
public function getResettoken(): ?string
{
return $this->resettoken;
}
public function setResettoken(?string $resettoken): self
{
$this->resettoken = $resettoken;
return $this;
}
/**
* @return Collection|BFFestival[]
*/
public function getOwnedfestivals(): Collection
{
return $this->ownedfestivals;
}
public function addOwnedfestival(BFFestival $ownedfestival): self
{
if (!$this->ownedfestivals->contains($ownedfestival)) {
$this->ownedfestivals[] = $ownedfestival;
$ownedfestival->setOwner($this);
}
return $this;
}
public function removeOwnedfestival(BFFestival $ownedfestival): self
{
if ($this->ownedfestivals->contains($ownedfestival)) {
$this->ownedfestivals->removeElement($ownedfestival);
// set the owning side to null (unless already changed)
if ($ownedfestival->getOwner() === $this) {
$ownedfestival->setOwner(null);
}
}
return $this;
}
/**
* @return Collection|BFFestival[]
*/
public function getAdministratorfestivals(): Collection
{
return $this->administratorfestivals;
}
public function addAdministratorfestival(BFFestival $administratorfestival): self
{
if (!$this->administratorfestivals->contains($administratorfestival)) {
$this->administratorfestivals[] = $administratorfestival;
$administratorfestival->addAdministrator($this);
}
return $this;
}
public function removeAdministratorfestival(BFFestival $administratorfestival): self
{
if ($this->administratorfestivals->contains($administratorfestival)) {
$this->administratorfestivals->removeElement($administratorfestival);
$administratorfestival->removeAdministrator($this);
}
return $this;
}
/**
* @return Collection|BFSubscription[]
*/
public function getSubscriptions(): Collection
{
return $this->subscriptions;
}
public function addSubscription(BFSubscription $subscription): self
{
if (!$this->subscriptions->contains($subscription)) {
$this->subscriptions[] = $subscription;
$subscription->setUser($this);
}
return $this;
}
public function removeSubscription(BFSubscription $subscription): self
{
if ($this->subscriptions->contains($subscription)) {
$this->subscriptions->removeElement($subscription);
// set the owning side to null (unless already changed)
if ($subscription->getUser() === $this) {
$subscription->setUser(null);
}
}
return $this;
}
public function getCreationdate(): ?\DateTimeInterface
{
return $this->creationdate;
}
public function setCreationdate(?\DateTimeInterface $creationdate): self
{
$this->creationdate = $creationdate;
return $this;
}
public function getInscriptionuser(): ?BFInscriptionUser
{
return $this->inscriptionuser;
}
public function setInscriptionuser(?BFInscriptionUser $inscriptionuser): self
{
$this->inscriptionuser = $inscriptionuser;
// set (or unset) the owning side of the relation if necessary
$newUser = null === $inscriptionuser ? null : $this;
if ($inscriptionuser->getUser() !== $newUser) {
$inscriptionuser->setUser($newUser);
}
return $this;
}
/**
* @return Collection|BFChallenge[]
*/
public function getOwnedChallenges(): Collection
{
return $this->ownedChallenges;
}
public function addOwnedChallenge(BFChallenge $ownedChallenge): self
{
if (!$this->ownedChallenges->contains($ownedChallenge)) {
$this->ownedChallenges[] = $ownedChallenge;
$ownedChallenge->setOwner($this);
}
return $this;
}
public function removeOwnedChallenge(BFChallenge $ownedChallenge): self
{
if ($this->ownedChallenges->contains($ownedChallenge)) {
$this->ownedChallenges->removeElement($ownedChallenge);
// set the owning side to null (unless already changed)
if ($ownedChallenge->getOwner() === $this) {
$ownedChallenge->setOwner(null);
}
}
return $this;
}
/**
* @return Collection|BFChallenge[]
*/
public function getAdminChallenges(): Collection
{
return $this->adminChallenges;
}
public function addAdminChallenge(BFChallenge $adminChallenge): self
{
if (!$this->adminChallenges->contains($adminChallenge)) {
$this->adminChallenges[] = $adminChallenge;
$adminChallenge->addAdministrator($this);
}
return $this;
}
public function removeAdminChallenge(BFChallenge $adminChallenge): self
{
if ($this->adminChallenges->contains($adminChallenge)) {
$this->adminChallenges->removeElement($adminChallenge);
$adminChallenge->removeAdministrator($this);
}
return $this;
}
/**
* @return Collection|BFPaymentIntentEdition[]
*/
public function getBFPaymentIntentEditions(): Collection
{
return $this->bFPaymentIntentEditions;
}
public function addBFPaymentIntentEdition(BFPaymentIntentEdition $bFPaymentIntentEdition): self
{
if (!$this->bFPaymentIntentEditions->contains($bFPaymentIntentEdition)) {
$this->bFPaymentIntentEditions[] = $bFPaymentIntentEdition;
$bFPaymentIntentEdition->setUser($this);
}
return $this;
}
public function removeBFPaymentIntentEdition(BFPaymentIntentEdition $bFPaymentIntentEdition): self
{
if ($this->bFPaymentIntentEditions->contains($bFPaymentIntentEdition)) {
$this->bFPaymentIntentEditions->removeElement($bFPaymentIntentEdition);
// set the owning side to null (unless already changed)
if ($bFPaymentIntentEdition->getUser() === $this) {
$bFPaymentIntentEdition->setUser(null);
}
}
return $this;
}
}