<?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\Component\Validator\Constraints as Assert;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
/**
* @ORM\Entity(repositoryClass="App\Repository\UserRepository")
* @UniqueEntity(
* fields = {"email"},
* message = "L'email indiqué est déjà utilisé !"
* )
*/
class User implements UserInterface
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="json")
*/
private $roles = [];
/**
* @ORM\Column(type="string", length=25, nullable=true)
*/
private $type;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $username;
/**
* @ORM\Column(type="string", length=255)
* @Assert\Email(
* message = "L'email '{{ value }}' n'est pas un email valide !"
* )
*/
private $email;
/**
* @ORM\Column(type="string", length=64)
* @Assert\Length(
* min = 8,
* minMessage = "Le mot de passe doit comporter au moins {{ limit }} caractères !",
* )
*/
private $password;
/**
* @Assert\EqualTo(propertyPath="password", message="La confirmation du mot de passe ne correspond pas au mot de passe indiqué !")
*/
private $confirm_password;
/**
* @ORM\Column(type="boolean")
*/
private $accepteBdd;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $accepteTransmission;
/**
* @ORM\Column(type="boolean")
*/
private $accepteDroitRetrait;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Structure", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $structures;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ProductionCineAudio", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $productionsCineAudio;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ProductionCom", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $productionsCom;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PrestataireTechnique", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $prestatairesTechniques;
/**
* @ORM\OneToMany(targetEntity="App\Entity\PrestataireLogistique", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
*/
private $prestatairesLogistiques;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Action", mappedBy="user", cascade={"persist"}, orphanRemoval=true)
* @Assert\Valid()
* @ORM\OrderBy({"date" = "ASC"})
*/
private $actions;
/**
* @ORM\Column(type="string", length=25)
*/
private $statut;
/**
* @ORM\Column(type="datetime")
*/
private $statutDate;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $resetPassword;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $resetPasswordDate;
/**
* @ORM\Column(type="boolean")
*/
private $publication;
/**
* @ORM\Column(type="datetime")
*/
private $createdAt;
public function __construct()
{
$this->structures = new ArrayCollection();
$this->productionsCineAudio = new ArrayCollection();
$this->productionsCom = new ArrayCollection();
$this->prestatairesTechniques = new ArrayCollection();
$this->prestatairesLogistiques = new ArrayCollection();
$this->roles = ["ROLE_USER"];
$this->actions = new ArrayCollection();
$this->statut = 'création';
$this->publication = 0;
$this->statutDate = new \DateTime();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @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 getType(): ?string
{
return $this->type;
}
public function setType(string $type): self
{
$this->type = $type;
return $this;
}
public function getUsername(): ?string
{
return $this->email;
}
public function setUsername(string $username): self
{
$this->username = $username;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): self
{
$this->email = $email;
return $this;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): self
{
$this->password = $password;
return $this;
}
public function getConfirmPassword()
{
return $this->confirm_password;
}
public function setConfirmPassword($confirm_password): void
{
$this->confirm_password = $confirm_password;
}
public function getAccepteBdd(): ?bool
{
return $this->accepteBdd;
}
public function setAccepteBdd(bool $accepteBdd): self
{
$this->accepteBdd = $accepteBdd;
return $this;
}
public function getAccepteTransmission(): ?bool
{
return $this->accepteTransmission;
}
public function setAccepteTransmission(?bool $accepteTransmission): self
{
$this->accepteTransmission = $accepteTransmission;
return $this;
}
public function getAccepteDroitRetrait(): ?bool
{
return $this->accepteDroitRetrait;
}
public function setAccepteDroitRetrait(bool $accepteDroitRetrait): self
{
$this->accepteDroitRetrait = $accepteDroitRetrait;
return $this;
}
public function eraseCredentials()
{
}
public function getSalt(){
return null;
}
/**
* @return Collection|Structure[]
*/
public function getStructures(): Collection
{
return $this->structures;
}
public function addStructure(Structure $structure): self
{
if (!$this->structures->contains($structure)) {
$this->structures[] = $structure;
$structure->setUser($this);
}
return $this;
}
public function removeStructure(Structure $structure): self
{
if ($this->structures->contains($structure)) {
$this->structures->removeElement($structure);
// set the owning side to null (unless already changed)
if ($structure->getUser() === $this) {
$structure->setUser(null);
}
}
return $this;
}
/**
* @return Collection|ProductionCineAudio[]
*/
public function getProductionsCineAudio(): Collection
{
return $this->productionsCineAudio;
}
public function addProductionCineAudio(ProductionCineAudio $productionCineAudio): self
{
if (!$this->productionsCineAudio->contains($productionCineAudio)) {
$this->productionsCineAudio[] = $productionCineAudio;
$productionCineAudio->setUser($this);
}
return $this;
}
public function removeProductionCineAudio(ProductionCineAudio $productionCineAudio): self
{
if ($this->productionsCineAudio->contains($productionCineAudio)) {
$this->productionsCineAudio->removeElement($productionCineAudio);
// set the owning side to null (unless already changed)
if ($productionCineAudio->getUser() === $this) {
$productionCineAudio->setUser(null);
}
}
return $this;
}
/**
* @return Collection|ProductionCom[]
*/
public function getProductionsCom(): Collection
{
return $this->productionsCom;
}
public function addProductionCom(ProductionCom $productionCom): self
{
if (!$this->productionsCom->contains($productionCom)) {
$this->productionsCom[] = $productionCom;
$productionCom->setUser($this);
}
return $this;
}
public function removeProductionCom(ProductionCom $productionCom): self
{
if ($this->productionsCom->contains($productionCom)) {
$this->productionsCom->removeElement($productionCom);
// set the owning side to null (unless already changed)
if ($productionCom->getUser() === $this) {
$productionCom->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PrestataireTechnique[]
*/
public function getPrestatairesTechniques(): Collection
{
return $this->prestatairesTechniques;
}
public function addPrestataireTechnique(PrestataireTechnique $prestatairesTechniques): self
{
if (!$this->prestatairesTechniques->contains($prestatairesTechniques)) {
$this->prestatairesTechniques[] = $prestatairesTechniques;
$prestatairesTechniques->setUser($this);
}
return $this;
}
public function removePrestataireTechnique(PrestataireTechnique $prestatairesTechniques): self
{
if ($this->prestatairesTechniques->contains($prestatairesTechniques)) {
$this->prestatairesTechniques->removeElement($prestatairesTechniques);
// set the owning side to null (unless already changed)
if ($prestatairesTechniques->getUser() === $this) {
$prestatairesTechniques->setUser(null);
}
}
return $this;
}
/**
* @return Collection|PrestataireLogistique[]
*/
public function getPrestatairesLogistiques(): Collection
{
return $this->prestatairesLogistiques;
}
public function addPrestataireLogistique(PrestataireLogistique $prestatairesLogistiques): self
{
if (!$this->prestatairesLogistiques->contains($prestatairesLogistiques)) {
$this->prestatairesLogistiques[] = $prestatairesLogistiques;
$prestatairesLogistiques->setUser($this);
}
return $this;
}
public function removePrestataireLogistique(PrestataireLogistique $prestatairesLogistiques): self
{
if ($this->prestatairesLogistiques->contains($prestatairesLogistiques)) {
$this->prestatairesLogistiques->removeElement($prestatairesLogistiques);
// set the owning side to null (unless already changed)
if ($prestatairesLogistiques->getUser() === $this) {
$prestatairesLogistiques->setUser(null);
}
}
return $this;
}
/**
* @return Collection|Action[]
*/
public function getActions(): Collection
{
return $this->actions;
}
public function addAction(Action $action): self
{
if (!$this->actions->contains($action)) {
$this->actions[] = $action;
$action->setUser($this);
}
return $this;
}
public function removeAction(Action $action): self
{
if ($this->actions->contains($action)) {
$this->actions->removeElement($action);
// set the owning side to null (unless already changed)
if ($action->getUser() === $this) {
$action->setUser(null);
}
}
return $this;
}
public function getStatut(): ?string
{
return $this->statut;
}
public function setStatut(string $statut): self
{
$this->statut = $statut;
return $this;
}
public function getStatutDate(): ?\DateTimeInterface
{
return $this->statutDate;
}
public function setStatutDate(\DateTimeInterface $statutDate): self
{
$this->statutDate = $statutDate;
return $this;
}
public function getResetPassword(): ?string
{
return $this->resetPassword;
}
public function setResetPassword(?string $resetPassword): self
{
$this->resetPassword = $resetPassword;
return $this;
}
public function getResetPasswordDate(): ?\DateTimeInterface
{
return $this->resetPasswordDate;
}
public function setResetPasswordDate(?\DateTimeInterface $resetPasswordDate): self
{
$this->resetPasswordDate = $resetPasswordDate;
return $this;
}
public function getPublication(): ?bool
{
return $this->publication;
}
public function setPublication(bool $publication): self
{
$this->publication = $publication;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
}