From 2131abdd5fcd01522e7a6062da3d5a2fe782436d Mon Sep 17 00:00:00 2001 From: marvin Date: Mon, 18 Nov 2024 16:39:14 +0100 Subject: [PATCH] =?UTF-8?q?entit=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Entity/Etat.php | 81 +++++++++ src/Entity/Lieu.php | 141 +++++++++++++++ src/Entity/Participant.php | 209 +++++++++++++++++++++++ src/Entity/Site.php | 118 +++++++++++++ src/Entity/Sortie.php | 99 ++++++++--- src/Entity/User.php | 111 ------------ src/Entity/Ville.php | 96 +++++++++++ src/Repository/EtatRepository.php | 43 +++++ src/Repository/LieuRepository.php | 43 +++++ src/Repository/ParticipantRepository.php | 43 +++++ src/Repository/SiteRepository.php | 43 +++++ src/Repository/VilleRepository.php | 43 +++++ 12 files changed, 932 insertions(+), 138 deletions(-) create mode 100644 src/Entity/Etat.php create mode 100644 src/Entity/Lieu.php create mode 100644 src/Entity/Participant.php create mode 100644 src/Entity/Site.php delete mode 100644 src/Entity/User.php create mode 100644 src/Entity/Ville.php create mode 100644 src/Repository/EtatRepository.php create mode 100644 src/Repository/LieuRepository.php create mode 100644 src/Repository/ParticipantRepository.php create mode 100644 src/Repository/SiteRepository.php create mode 100644 src/Repository/VilleRepository.php diff --git a/src/Entity/Etat.php b/src/Entity/Etat.php new file mode 100644 index 0000000..231b06a --- /dev/null +++ b/src/Entity/Etat.php @@ -0,0 +1,81 @@ + + */ + #[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'etat')] + private Collection $sorties; + + public function __construct() + { + $this->idEtat = Uuid::v4(); // Génération automatique d'un UUID + $this->sorties = new ArrayCollection(); + } + + public function getIdEtat(): ?Uuid + { + return $this->idEtat; + } + + public function getLibelle(): ?string + { + return $this->libelle; + } + + public function setLibelle(string $libelle): self + { + $this->libelle = $libelle; + + return $this; + } + + /** + * @return Collection + */ + public function getSorties(): Collection + { + return $this->sorties; + } + + public function addSortie(Sortie $sortie): self + { + if (!$this->sorties->contains($sortie)) { + $this->sorties->add($sortie); + $sortie->setEtat($this); + } + + return $this; + } + + public function removeSortie(Sortie $sortie): self + { + if ($this->sorties->removeElement($sortie)) { + // Set the owning side to null (unless already changed) + if ($sortie->getEtat() === $this) { + $sortie->setEtat(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Lieu.php b/src/Entity/Lieu.php new file mode 100644 index 0000000..a99311d --- /dev/null +++ b/src/Entity/Lieu.php @@ -0,0 +1,141 @@ + + */ + #[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'lieu')] + private Collection $sorties; + + #[ORM\ManyToOne(inversedBy: 'lieux')] + private ?Ville $ville = null; + + public function __construct() + { + $this->idLieu = Uuid::v4(); // Génération automatique d'un UUID + $this->sorties = new ArrayCollection(); + } + + public function getIdLieu(): ?Uuid + { + return $this->idLieu; + } + + public function getNom(): ?string + { + return $this->nom; + } + + public function setNom(string $nom): self + { + $this->nom = $nom; + + return $this; + } + + public function getRue(): ?string + { + return $this->rue; + } + + public function setRue(?string $rue): self + { + $this->rue = $rue; + + return $this; + } + + public function getLatitude(): ?float + { + return $this->latitude; + } + + public function setLatitude(?float $latitude): self + { + $this->latitude = $latitude; + + return $this; + } + + public function getLongitude(): ?float + { + return $this->longitude; + } + + public function setLongitude(?float $longitude): self + { + $this->longitude = $longitude; + + return $this; + } + + /** + * @return Collection + */ + public function getSorties(): Collection + { + return $this->sorties; + } + + public function addSortie(Sortie $sortie): self + { + if (!$this->sorties->contains($sortie)) { + $this->sorties->add($sortie); + $sortie->setLieu($this); + } + + return $this; + } + + public function removeSortie(Sortie $sortie): self + { + if ($this->sorties->removeElement($sortie)) { + // Set the owning side to null (unless already changed) + if ($sortie->getLieu() === $this) { + $sortie->setLieu(null); + } + } + + return $this; + } + + public function getVille(): ?Ville + { + return $this->ville; + } + + public function setVille(?Ville $ville): self + { + $this->ville = $ville; + + return $this; + } +} diff --git a/src/Entity/Participant.php b/src/Entity/Participant.php new file mode 100644 index 0000000..2f61b0b --- /dev/null +++ b/src/Entity/Participant.php @@ -0,0 +1,209 @@ + + */ + #[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'participant')] + private Collection $sorties; + + public function __construct() + { + $this->idParticipant = Uuid::v4(); // Génération automatique de l'UUID + $this->sorties = new ArrayCollection(); + } + + public function getIdParticipant(): ?Uuid + { + return $this->idParticipant; + } + + public function getNom(): ?string + { + return $this->nom; + } + + public function setNom(string $nom): self + { + $this->nom = $nom; + + return $this; + } + + public function getPrénom(): ?string + { + return $this->prénom; + } + + public function setPrénom(string $prénom): self + { + $this->prénom = $prénom; + + return $this; + } + + public function getTelephone(): ?string + { + return $this->telephone; + } + + public function setTelephone(?string $telephone): self + { + $this->telephone = $telephone; + + return $this; + } + + public function getMail(): ?string + { + return $this->mail; + } + + public function setMail(?string $mail): self + { + $this->mail = $mail; + + return $this; + } + + public function isAdministrateur(): ?bool + { + return $this->administrateur; + } + + public function setAdministrateur(bool $administrateur): self + { + $this->administrateur = $administrateur; + + return $this; + } + + public function isActif(): ?bool + { + return $this->actif; + } + + public function setActif(bool $actif): self + { + $this->actif = $actif; + + return $this; + } + + public function getRoles(): array + { + $roles = $this->roles; + // Garantit que chaque utilisateur a au moins le rôle ROLE_USER + $roles[] = 'ROLE_USER'; + + return array_unique($roles); + } + + /** + * @param list $roles + */ + public function setRoles(array $roles): self + { + $this->roles = $roles; + + return $this; + } + + public function getPassword(): ?string + { + return $this->password; + } + + public function setPassword(string $password): self + { + $this->password = $password; + + return $this; + } + + public function getSite(): ?Site + { + return $this->site; + } + + public function setSite(?Site $site): self + { + $this->site = $site; + + return $this; + } + + /** + * @return Collection + */ + public function getSorties(): Collection + { + return $this->sorties; + } + + public function addSortie(Sortie $sortie): self + { + if (!$this->sorties->contains($sortie)) { + $this->sorties->add($sortie); + $sortie->setParticipant($this); + } + + return $this; + } + + public function removeSortie(Sortie $sortie): self + { + if ($this->sorties->removeElement($sortie)) { + // Set the owning side to null (unless already changed) + if ($sortie->getParticipant() === $this) { + $sortie->setParticipant(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Site.php b/src/Entity/Site.php new file mode 100644 index 0000000..890bf63 --- /dev/null +++ b/src/Entity/Site.php @@ -0,0 +1,118 @@ + + */ + #[ORM\OneToMany(targetEntity: Sortie::class, mappedBy: 'site')] + private Collection $sorties; + + /** + * @var Collection + */ + #[ORM\OneToMany(targetEntity: Participant::class, mappedBy: 'site')] + private Collection $participants; + + public function __construct() + { + $this->idSite = Uuid::v4(); // Génération automatique de l'UUID + $this->sorties = new ArrayCollection(); + $this->participants = new ArrayCollection(); + } + + public function getIdSite(): ?Uuid + { + return $this->idSite; + } + + public function getNom(): ?string + { + return $this->nom; + } + + public function setNom(string $nom): self + { + $this->nom = $nom; + + return $this; + } + + /** + * @return Collection + */ + public function getSorties(): Collection + { + return $this->sorties; + } + + public function addSorty(Sortie $sorty): self + { + if (!$this->sorties->contains($sorty)) { + $this->sorties->add($sorty); + $sorty->setSite($this); + } + + return $this; + } + + public function removeSorty(Sortie $sorty): self + { + if ($this->sorties->removeElement($sorty)) { + // Set the owning side to null (unless already changed) + if ($sorty->getSite() === $this) { + $sorty->setSite(null); + } + } + + return $this; + } + + /** + * @return Collection + */ + public function getParticipants(): Collection + { + return $this->participants; + } + + public function addParticipant(Participant $participant): self + { + if (!$this->participants->contains($participant)) { + $this->participants->add($participant); + $participant->setSite($this); + } + + return $this; + } + + public function removeParticipant(Participant $participant): self + { + if ($this->participants->removeElement($participant)) { + // Set the owning side to null (unless already changed) + if ($participant->getSite() === $this) { + $participant->setSite(null); + } + } + + return $this; + } +} diff --git a/src/Entity/Sortie.php b/src/Entity/Sortie.php index 2213dce..bec3d0e 100644 --- a/src/Entity/Sortie.php +++ b/src/Entity/Sortie.php @@ -5,19 +5,16 @@ namespace App\Entity; use App\Repository\SortieRepository; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping as ORM; -use Symfony\Bridge\Doctrine\Types\UuidType; use Symfony\Component\Uid\Uuid; #[ORM\Entity(repositoryClass: SortieRepository::class)] class Sortie { #[ORM\Id] - #[ORM\Column(type: UuidType::NAME, unique: true)] + #[ORM\Column(type: 'uuid', unique: true)] #[ORM\GeneratedValue(strategy: 'CUSTOM')] #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')] - private ?Uuid $idSortie; - - + private ?Uuid $idSortie = null; #[ORM\Column(length: 255)] private ?string $nom = null; @@ -40,35 +37,35 @@ class Sortie #[ORM\Column(nullable: true)] private ?int $état = null; + #[ORM\ManyToOne(inversedBy: 'sorties')] + private ?Site $site = null; + + #[ORM\ManyToOne(inversedBy: 'sorties')] + private ?Participant $participant = null; + + #[ORM\ManyToOne(inversedBy: 'sorties')] + private ?Lieu $lieu = null; + + #[ORM\ManyToOne(inversedBy: 'Sortie')] + private ?Etat $etat = null; + public function __construct() { // Génère un UUID automatiquement lors de la création de l'entité - $this->id = Uuid::v4(); + $this->idSortie = Uuid::v4(); } - public function getId(): ?Uuid - { - return $this->id; - } - - public function getIdSortie(): ?int + public function getIdSortie(): ?Uuid { return $this->idSortie; } - public function setIdSortie(int $idSortie): static - { - $this->idSortie = $idSortie; - - return $this; - } - public function getNom(): ?string { return $this->nom; } - public function setNom(string $nom): static + public function setNom(string $nom): self { $this->nom = $nom; @@ -80,7 +77,7 @@ class Sortie return $this->dateHeureDebut; } - public function setDateHeureDebut(?\DateTimeInterface $dateHeureDebut): static + public function setDateHeureDebut(?\DateTimeInterface $dateHeureDebut): self { $this->dateHeureDebut = $dateHeureDebut; @@ -92,7 +89,7 @@ class Sortie return $this->durée; } - public function setDurée(?int $durée): static + public function setDurée(?int $durée): self { $this->durée = $durée; @@ -104,7 +101,7 @@ class Sortie return $this->dateLimiteInscription; } - public function setDateLimiteInscription(?\DateTimeInterface $dateLimiteInscription): static + public function setDateLimiteInscription(?\DateTimeInterface $dateLimiteInscription): self { $this->dateLimiteInscription = $dateLimiteInscription; @@ -116,7 +113,7 @@ class Sortie return $this->nbInscriptionsMax; } - public function setNbInscriptionsMax(?int $nbInscriptionsMax): static + public function setNbInscriptionsMax(?int $nbInscriptionsMax): self { $this->nbInscriptionsMax = $nbInscriptionsMax; @@ -128,22 +125,70 @@ class Sortie return $this->infosSortie; } - public function setInfosSortie(?string $infosSortie): static + public function setInfosSortie(?string $infosSortie): self { $this->infosSortie = $infosSortie; return $this; } - public function getétat(): ?int + public function getÉtat(): ?int { return $this->état; } - public function setétat(?int $état): static + public function setÉtat(?int $état): self { $this->état = $état; return $this; } + + public function getSite(): ?Site + { + return $this->site; + } + + public function setSite(?Site $site): self + { + $this->site = $site; + + return $this; + } + + public function getParticipant(): ?Participant + { + return $this->participant; + } + + public function setParticipant(?Participant $participant): self + { + $this->participant = $participant; + + return $this; + } + + public function getLieu(): ?Lieu + { + return $this->lieu; + } + + public function setLieu(?Lieu $lieu): self + { + $this->lieu = $lieu; + + return $this; + } + + public function getEtat(): ?Etat + { + return $this->etat; + } + + public function setEtat(?Etat $etat): static + { + $this->etat = $etat; + + return $this; + } } diff --git a/src/Entity/User.php b/src/Entity/User.php deleted file mode 100644 index ef1a35e..0000000 --- a/src/Entity/User.php +++ /dev/null @@ -1,111 +0,0 @@ - The user roles - */ - #[ORM\Column] - private array $roles = []; - - /** - * @var string The hashed password - */ - #[ORM\Column] - private ?string $password = null; - - public function getId(): ?int - { - return $this->id; - } - - public function getEmail(): ?string - { - return $this->email; - } - - public function setEmail(string $email): static - { - $this->email = $email; - - return $this; - } - - /** - * A visual identifier that represents this user. - * - * @see UserInterface - */ - public function getUserIdentifier(): string - { - return (string) $this->email; - } - - /** - * @see UserInterface - * - * @return list - */ - public function getRoles(): array - { - $roles = $this->roles; - // guarantee every user at least has ROLE_USER - $roles[] = 'ROLE_USER'; - - return array_unique($roles); - } - - /** - * @param list $roles - */ - public function setRoles(array $roles): static - { - $this->roles = $roles; - - return $this; - } - - /** - * @see PasswordAuthenticatedUserInterface - */ - public function getPassword(): ?string - { - return $this->password; - } - - public function setPassword(string $password): static - { - $this->password = $password; - - return $this; - } - - /** - * @see UserInterface - */ - public function eraseCredentials(): void - { - // If you store any temporary, sensitive data on the user, clear it here - // $this->plainPassword = null; - } -} diff --git a/src/Entity/Ville.php b/src/Entity/Ville.php new file mode 100644 index 0000000..ca93afe --- /dev/null +++ b/src/Entity/Ville.php @@ -0,0 +1,96 @@ + + */ + #[ORM\OneToMany(targetEntity: Lieu::class, mappedBy: 'ville')] + private Collection $lieux; + + public function __construct() + { + $this->idVille = Uuid::v4(); // Génération automatique d'un UUID + $this->lieux = new ArrayCollection(); + } + + public function getIdVille(): ?Uuid + { + return $this->idVille; + } + + public function getNom(): ?string + { + return $this->nom; + } + + public function setNom(string $nom): self + { + $this->nom = $nom; + + return $this; + } + + public function getCodePostal(): ?int + { + return $this->codePostal; + } + + public function setCodePostal(?int $codePostal): self + { + $this->codePostal = $codePostal; + + return $this; + } + + /** + * @return Collection + */ + public function getLieux(): Collection + { + return $this->lieux; + } + + public function addLieu(Lieu $lieu): self + { + if (!$this->lieux->contains($lieu)) { + $this->lieux->add($lieu); + $lieu->setVille($this); + } + + return $this; + } + + public function removeLieu(Lieu $lieu): self + { + if ($this->lieux->removeElement($lieu)) { + // Set the owning side to null (unless already changed) + if ($lieu->getVille() === $this) { + $lieu->setVille(null); + } + } + + return $this; + } +} diff --git a/src/Repository/EtatRepository.php b/src/Repository/EtatRepository.php new file mode 100644 index 0000000..d045eb6 --- /dev/null +++ b/src/Repository/EtatRepository.php @@ -0,0 +1,43 @@ + + */ +class EtatRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Etat::class); + } + + // /** + // * @return Etat[] Returns an array of Etat objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('e') + // ->andWhere('e.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('e.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Etat + // { + // return $this->createQueryBuilder('e') + // ->andWhere('e.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/LieuRepository.php b/src/Repository/LieuRepository.php new file mode 100644 index 0000000..8938a70 --- /dev/null +++ b/src/Repository/LieuRepository.php @@ -0,0 +1,43 @@ + + */ +class LieuRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Lieu::class); + } + + // /** + // * @return Lieu[] Returns an array of Lieu objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('l') + // ->andWhere('l.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('l.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Lieu + // { + // return $this->createQueryBuilder('l') + // ->andWhere('l.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/ParticipantRepository.php b/src/Repository/ParticipantRepository.php new file mode 100644 index 0000000..daa2330 --- /dev/null +++ b/src/Repository/ParticipantRepository.php @@ -0,0 +1,43 @@ + + */ +class ParticipantRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Participant::class); + } + + // /** + // * @return Participant[] Returns an array of Participant objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('p.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Participant + // { + // return $this->createQueryBuilder('p') + // ->andWhere('p.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/SiteRepository.php b/src/Repository/SiteRepository.php new file mode 100644 index 0000000..2ef4b21 --- /dev/null +++ b/src/Repository/SiteRepository.php @@ -0,0 +1,43 @@ + + */ +class SiteRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Site::class); + } + + // /** + // * @return Site[] Returns an array of Site objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('s.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Site + // { + // return $this->createQueryBuilder('s') + // ->andWhere('s.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +} diff --git a/src/Repository/VilleRepository.php b/src/Repository/VilleRepository.php new file mode 100644 index 0000000..40501e7 --- /dev/null +++ b/src/Repository/VilleRepository.php @@ -0,0 +1,43 @@ + + */ +class VilleRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, Ville::class); + } + + // /** + // * @return Ville[] Returns an array of Ville objects + // */ + // public function findByExampleField($value): array + // { + // return $this->createQueryBuilder('v') + // ->andWhere('v.exampleField = :val') + // ->setParameter('val', $value) + // ->orderBy('v.id', 'ASC') + // ->setMaxResults(10) + // ->getQuery() + // ->getResult() + // ; + // } + + // public function findOneBySomeField($value): ?Ville + // { + // return $this->createQueryBuilder('v') + // ->andWhere('v.exampleField = :val') + // ->setParameter('val', $value) + // ->getQuery() + // ->getOneOrNullResult() + // ; + // } +}