فهرست منبع

bascule de l'id des parties en uuid

garthh 2 روز پیش
والد
کامیت
f373e242a8
5فایلهای تغییر یافته به همراه95 افزوده شده و 30 حذف شده
  1. 31 0
      migrations/Version20250803150625.php
  2. 31 0
      migrations/Version20250803151721.php
  3. 18 0
      src/Controller/PartyController.php
  4. 15 4
      src/Entity/Party.php
  5. 0 26
      src/Form/PartyType.php

+ 31 - 0
migrations/Version20250803150625.php

@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace DoctrineMigrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20250803150625 extends AbstractMigration
+{
+    public function getDescription(): string
+    {
+        return '';
+    }
+
+    public function up(Schema $schema): void
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE party ADD new_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE party DROP new_id');
+    }
+}

+ 31 - 0
migrations/Version20250803151721.php

@@ -0,0 +1,31 @@
+<?php
+
+declare(strict_types=1);
+
+namespace DoctrineMigrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20250803151721 extends AbstractMigration
+{
+    public function getDescription(): string
+    {
+        return '';
+    }
+
+    public function up(Schema $schema): void
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE slot CHANGE party_id party_id BINARY(16) DEFAULT NULL COMMENT \'(DC2Type:uuid)\'');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->addSql('ALTER TABLE slot CHANGE party_id party_id BINARY(16) DEFAULT NULL');
+    }
+}

+ 18 - 0
src/Controller/PartyController.php

@@ -31,6 +31,24 @@ final class PartyController extends AbstractController
         ]);
     }
 
+    #[Route('/party/delete/{id}', name: 'app_party_delete', requirements: ['id' => '\d+'], methods: ['GET'])]
+    public function delete(?Party $party, EntityManager $manager, SlotRepository $slotRepository): Response
+    {
+        // Seuls gestionnaires (MANAGER), admin (ADMIN)
+        $user = $this->getUser();
+        if (!in_array('ROLE_ADMIN', $roles) && !in_array('ROLE_MANAGER', $roles)) {}
+
+    }
+
+    #[Route('/party/validate/{id}', name: 'app_party_delete', requirements: ['id' => '\d+'], methods: ['GET'])]
+    public function validate(?Party $party, EntityManager $manager, SlotRepository $slotRepository): Response
+    {
+        // Seuls gestionnaires (MANAGER), admin (ADMIN)
+        $user = $this->getUser();
+        if (!in_array('ROLE_ADMIN', $roles) && !in_array('ROLE_MANAGER', $roles)) {}
+            
+    }
+
     #[Route('/party/add/{id}', name: 'app_party_add', requirements: ['id' => '\d+'], methods: ['GET','POST'])]
     public function add(?Slot $slot, Request $request, SlotRepository $slotRepository, GamemasterRepository $gamemasterRepository, GameRepository $gameRepository, EntityManagerInterface $manager): Response
     {

+ 15 - 4
src/Entity/Party.php

@@ -7,14 +7,18 @@ use Doctrine\Common\Collections\ArrayCollection;
 use Doctrine\Common\Collections\Collection;
 use Doctrine\DBAL\Types\Types;
 use Doctrine\ORM\Mapping as ORM;
+use Symfony\Bridge\Doctrine\Types\UuidType;
+use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
+use Symfony\Component\Uid\Uuid;
 
 #[ORM\Entity(repositoryClass: PartyRepository::class)]
 class Party
 {
     #[ORM\Id]
-    #[ORM\GeneratedValue]
-    #[ORM\Column]
-    private ?int $id = null;
+    #[ORM\Column(type: UuidType::NAME, nullable: true)]
+    #[ORM\GeneratedValue(strategy: 'CUSTOM')]
+    #[ORM\CustomIdGenerator(class: 'doctrine.uuid_generator')]
+    private ?Uuid $id = null;
 
     #[ORM\ManyToOne(inversedBy: 'parties')]
     private ?Gamemaster $gamemaster = null;
@@ -65,11 +69,18 @@ class Party
         $this->slots = new ArrayCollection();
     }
 
-    public function getId(): ?int
+    public function getId(): ?Uuid
     {
         return $this->id;
     }
 
+    public function setId(Uuid $id): static
+    {
+        $this->id = $id;
+
+        return $this;
+    }
+
     public function getGamemaster(): ?Gamemaster
     {
         return $this->gamemaster;

+ 0 - 26
src/Form/PartyType.php

@@ -17,32 +17,6 @@ class PartyType extends AbstractType
     public function buildForm(FormBuilderInterface $builder, array $options): void
     {
         $builder
-            /*->add('gamemaster', EntityType::class, [
-                'class' => Gamemaster::class,
-                'choice_label' => 'preferedName',
-                'label' => 'Meneur(euse) de jeu',
-                'attr' => ['class' => 'input'],
-                'required' => false,
-                'expanded' => false,
-                'multiple' => false,
-                'label_attr' => ['class' => 'label'],
-                'choice_attr' => ['class' => 'select'],
-                'row_attr' => ['class' => 'field'],
-                'help_attr' => ['class' => 'help'],
-            ])
-            ->add('game', EntityType::class, [
-                'class' => Game::class,
-                'choice_label' => 'name',
-                'label' => 'Jeu',
-                'attr' => ['class' => 'input'],
-                'required' => false,
-                'expanded' => false,
-                'multiple' => false,
-                'label_attr' => ['class' => 'label'],
-                'choice_attr' => ['class' => 'select'],
-                'row_attr' => ['class' => 'field'],
-                'help_attr' => ['class' => 'help'],
-            ]) */
             ->add('description', null, [
                 'label' => 'Description',
                 'label_attr' => ['class' => 'label'],