src/Entity/BFUser.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\Security\Core\User\UserInterface;
  7. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  8. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntityValidator;
  9. use Doctrine\ORM\Mapping\UniqueConstraint;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\BFUserRepository")
  12.  * @UniqueEntity(
  13.  *     fields="email",
  14.  *     message="Email déjà utilisé"
  15.  * )
  16.  */
  17. class BFUser implements UserInterface
  18. {
  19.     /**
  20.      * @ORM\Id()
  21.      * @ORM\GeneratedValue()
  22.      * @ORM\Column(type="integer")
  23.      */
  24.     private $id;
  25.     /**
  26.      * @ORM\Column(type="string", length=180, unique=true)
  27.      */
  28.     private $email;
  29.     /**
  30.      * @ORM\Column(type="json")
  31.      */
  32.     private $roles = [];
  33.     /**
  34.      * @var string The hashed password
  35.      * @ORM\Column(type="string")
  36.      */
  37.     private $password;
  38.     
  39.     private $plainPassword;
  40.     /**
  41.      * @ORM\OneToOne(targetEntity="App\Entity\BFDescriptionUser", inversedBy="bfuser", cascade={"persist", "remove"})
  42.      * @ORM\JoinColumn(nullable=false)
  43.      */
  44.     private $description;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $resettoken;
  49.     /**
  50.      * @ORM\OneToMany(targetEntity="App\Entity\BFFestival", mappedBy="owner")
  51.      */ 
  52.     private $ownedfestivals;
  53.     /**
  54.      * @ORM\ManyToMany(targetEntity="App\Entity\BFFestival", mappedBy="administrators")
  55.      */
  56.     private $administratorfestivals;
  57.     /**
  58.      * @ORM\OneToMany(targetEntity="App\Entity\BFSubscription", mappedBy="user", cascade={"persist", "remove"}, orphanRemoval=true)
  59.      */
  60.     private $subscriptions;
  61.     /**
  62.      * @ORM\Column(type="datetime", nullable=true)
  63.      */
  64.     private $creationdate;
  65.     /**
  66.      * @ORM\OneToOne(targetEntity="App\Entity\BFInscriptionUser", mappedBy="user")
  67.      * @ORM\JoinColumn(onDelete="SET NULL")
  68.      */
  69.     private $inscriptionuser;
  70.     /**
  71.      * @ORM\OneToMany(targetEntity="App\Entity\BFChallenge", mappedBy="owner")
  72.      */
  73.     private $ownedChallenges;
  74.     /**
  75.      * @ORM\ManyToMany(targetEntity="App\Entity\BFChallenge", mappedBy="administrators")
  76.      */
  77.     private $adminChallenges;
  78.     /**
  79.      * @ORM\OneToMany(targetEntity="App\Entity\BFPaymentIntentEdition", mappedBy="user")
  80.      * @ORM\OrderBy({"id" = "DESC"})
  81.      */
  82.     private $bFPaymentIntentEditions;
  83.     
  84.     public function __construct()
  85.     {
  86.         $this->description = new BFDescriptionUser();
  87.         $this->ownedfestivals = new ArrayCollection();
  88.         $this->administratorfestivals = new ArrayCollection();
  89.         $this->subscriptions = new ArrayCollection();
  90.         $this->creationdate = new \DateTime('now');
  91.         $this->ownedChallenges = new ArrayCollection();
  92.         $this->adminChallenges = new ArrayCollection();
  93.         $this->bFPaymentIntentEditions = new ArrayCollection();
  94.     }
  95.     public function getId(): ?int
  96.     {
  97.         return $this->id;
  98.     }
  99.     public function getEmail(): ?string
  100.     {
  101.         return $this->email;
  102.     }
  103.     public function setEmail(string $email): self
  104.     {
  105.         $this->email $email;
  106.         return $this;
  107.     }
  108.     /**
  109.      * A visual identifier that represents this user.
  110.      *
  111.      * @see UserInterface
  112.      */
  113.     public function getUsername(): string
  114.     {
  115.         return (string) $this->email;
  116.     }
  117.     /**
  118.      * @see UserInterface
  119.      */
  120.     public function getRoles(): array
  121.     {
  122.         $roles $this->roles;
  123.         // guarantee every user at least has ROLE_USER
  124.         $roles[] = 'ROLE_USER';
  125.         return array_unique($roles);
  126.     }
  127.     public function setRoles(array $roles): self
  128.     {
  129.         $this->roles $roles;
  130.         return $this;
  131.     }
  132.     
  133.     public function getPlainPassword()
  134.     {
  135.         return $this->plainPassword;
  136.     }
  137.     public function setPlainPassword($password)
  138.     {
  139.         $this->plainPassword $password;
  140.     }
  141.     /**
  142.      * @see UserInterface
  143.      */
  144.     public function getPassword(): string
  145.     {
  146.         return (string) $this->password;
  147.     }
  148.     public function setPassword(string $password): self
  149.     {
  150.         $this->password $password;
  151.         return $this;
  152.     }
  153.     /**
  154.      * @see UserInterface
  155.      */
  156.     public function getSalt()
  157.     {
  158.         // not needed when using the "bcrypt" algorithm in security.yaml
  159.     }
  160.     /**
  161.      * @see UserInterface
  162.      */
  163.     public function eraseCredentials()
  164.     {
  165.         // If you store any temporary, sensitive data on the user, clear it here
  166.         // $this->plainPassword = null;
  167.     }
  168.     public function getDescription(): ?BFDescriptionUser
  169.     {
  170.         return $this->description;
  171.     }
  172.     public function setDescription(BFDescriptionUser $description): self
  173.     {
  174.         $this->description $description;
  175.         return $this;
  176.     }
  177.     public function getResettoken(): ?string
  178.     {
  179.         return $this->resettoken;
  180.     }
  181.     public function setResettoken(?string $resettoken): self
  182.     {
  183.         $this->resettoken $resettoken;
  184.         return $this;
  185.     }
  186.     /**
  187.      * @return Collection|BFFestival[]
  188.      */
  189.     public function getOwnedfestivals(): Collection
  190.     {
  191.         return $this->ownedfestivals;
  192.     }
  193.     public function addOwnedfestival(BFFestival $ownedfestival): self
  194.     {
  195.         if (!$this->ownedfestivals->contains($ownedfestival)) {
  196.             $this->ownedfestivals[] = $ownedfestival;
  197.             $ownedfestival->setOwner($this);
  198.         }
  199.         return $this;
  200.     }
  201.     public function removeOwnedfestival(BFFestival $ownedfestival): self
  202.     {
  203.         if ($this->ownedfestivals->contains($ownedfestival)) {
  204.             $this->ownedfestivals->removeElement($ownedfestival);
  205.             // set the owning side to null (unless already changed)
  206.             if ($ownedfestival->getOwner() === $this) {
  207.                 $ownedfestival->setOwner(null);
  208.             }
  209.         }
  210.         return $this;
  211.     }
  212.     /**
  213.      * @return Collection|BFFestival[]
  214.      */
  215.     public function getAdministratorfestivals(): Collection
  216.     {
  217.         return $this->administratorfestivals;
  218.     }
  219.     public function addAdministratorfestival(BFFestival $administratorfestival): self
  220.     {
  221.         if (!$this->administratorfestivals->contains($administratorfestival)) {
  222.             $this->administratorfestivals[] = $administratorfestival;
  223.             $administratorfestival->addAdministrator($this);
  224.         }
  225.         return $this;
  226.     }
  227.     public function removeAdministratorfestival(BFFestival $administratorfestival): self
  228.     {
  229.         if ($this->administratorfestivals->contains($administratorfestival)) {
  230.             $this->administratorfestivals->removeElement($administratorfestival);
  231.             $administratorfestival->removeAdministrator($this);
  232.         }
  233.         return $this;
  234.     }
  235.     /**
  236.      * @return Collection|BFSubscription[]
  237.      */
  238.     public function getSubscriptions(): Collection
  239.     {
  240.         return $this->subscriptions;
  241.     }
  242.     public function addSubscription(BFSubscription $subscription): self
  243.     {
  244.         if (!$this->subscriptions->contains($subscription)) {
  245.             $this->subscriptions[] = $subscription;
  246.             $subscription->setUser($this);
  247.         }
  248.         return $this;
  249.     }
  250.     public function removeSubscription(BFSubscription $subscription): self
  251.     {
  252.         if ($this->subscriptions->contains($subscription)) {
  253.             $this->subscriptions->removeElement($subscription);
  254.             // set the owning side to null (unless already changed)
  255.             if ($subscription->getUser() === $this) {
  256.                 $subscription->setUser(null);
  257.             }
  258.         }
  259.         return $this;
  260.     }
  261.     public function getCreationdate(): ?\DateTimeInterface
  262.     {
  263.         return $this->creationdate;
  264.     }
  265.     public function setCreationdate(?\DateTimeInterface $creationdate): self
  266.     {
  267.         $this->creationdate $creationdate;
  268.         return $this;
  269.     }
  270.     public function getInscriptionuser(): ?BFInscriptionUser
  271.     {
  272.         return $this->inscriptionuser;
  273.     }
  274.     public function setInscriptionuser(?BFInscriptionUser $inscriptionuser): self
  275.     {
  276.         $this->inscriptionuser $inscriptionuser;
  277.         // set (or unset) the owning side of the relation if necessary
  278.         $newUser null === $inscriptionuser null $this;
  279.         if ($inscriptionuser->getUser() !== $newUser) {
  280.             $inscriptionuser->setUser($newUser);
  281.         }
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return Collection|BFChallenge[]
  286.      */
  287.     public function getOwnedChallenges(): Collection
  288.     {
  289.         return $this->ownedChallenges;
  290.     }
  291.     public function addOwnedChallenge(BFChallenge $ownedChallenge): self
  292.     {
  293.         if (!$this->ownedChallenges->contains($ownedChallenge)) {
  294.             $this->ownedChallenges[] = $ownedChallenge;
  295.             $ownedChallenge->setOwner($this);
  296.         }
  297.         return $this;
  298.     }
  299.     public function removeOwnedChallenge(BFChallenge $ownedChallenge): self
  300.     {
  301.         if ($this->ownedChallenges->contains($ownedChallenge)) {
  302.             $this->ownedChallenges->removeElement($ownedChallenge);
  303.             // set the owning side to null (unless already changed)
  304.             if ($ownedChallenge->getOwner() === $this) {
  305.                 $ownedChallenge->setOwner(null);
  306.             }
  307.         }
  308.         return $this;
  309.     }
  310.     /**
  311.      * @return Collection|BFChallenge[]
  312.      */
  313.     public function getAdminChallenges(): Collection
  314.     {
  315.         return $this->adminChallenges;
  316.     }
  317.     public function addAdminChallenge(BFChallenge $adminChallenge): self
  318.     {
  319.         if (!$this->adminChallenges->contains($adminChallenge)) {
  320.             $this->adminChallenges[] = $adminChallenge;
  321.             $adminChallenge->addAdministrator($this);
  322.         }
  323.         return $this;
  324.     }
  325.     public function removeAdminChallenge(BFChallenge $adminChallenge): self
  326.     {
  327.         if ($this->adminChallenges->contains($adminChallenge)) {
  328.             $this->adminChallenges->removeElement($adminChallenge);
  329.             $adminChallenge->removeAdministrator($this);
  330.         }
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return Collection|BFPaymentIntentEdition[]
  335.      */
  336.     public function getBFPaymentIntentEditions(): Collection
  337.     {
  338.         return $this->bFPaymentIntentEditions;
  339.     }
  340.     public function addBFPaymentIntentEdition(BFPaymentIntentEdition $bFPaymentIntentEdition): self
  341.     {
  342.         if (!$this->bFPaymentIntentEditions->contains($bFPaymentIntentEdition)) {
  343.             $this->bFPaymentIntentEditions[] = $bFPaymentIntentEdition;
  344.             $bFPaymentIntentEdition->setUser($this);
  345.         }
  346.         return $this;
  347.     }
  348.     public function removeBFPaymentIntentEdition(BFPaymentIntentEdition $bFPaymentIntentEdition): self
  349.     {
  350.         if ($this->bFPaymentIntentEditions->contains($bFPaymentIntentEdition)) {
  351.             $this->bFPaymentIntentEditions->removeElement($bFPaymentIntentEdition);
  352.             // set the owning side to null (unless already changed)
  353.             if ($bFPaymentIntentEdition->getUser() === $this) {
  354.                 $bFPaymentIntentEdition->setUser(null);
  355.             }
  356.         }
  357.         return $this;
  358.     }
  359. }