diff --git a/.php-version b/.php-version new file mode 100644 index 0000000..223a939 --- /dev/null +++ b/.php-version @@ -0,0 +1 @@ +8.3 \ No newline at end of file diff --git a/src/Controller/EmojiController.php b/src/Controller/EmojiController.php index 3b3bac2..4ad00bb 100644 --- a/src/Controller/EmojiController.php +++ b/src/Controller/EmojiController.php @@ -24,6 +24,34 @@ class EmojiController extends AbstractController ]); } + #[Route('/add/{code}', name: 'add')] + public function addEmojiDebug(string $code, EntityManagerInterface $entityManager) { + $emoji = new Emoji(); + $emoji->setCode($code); + $emoji->setName('Default Name'); + $emoji->setStrength(1.0); + $emoji->setToughness(1.0); + $emoji->setIntelligence(1.0); + $emoji->setSpeed(1.0); + $emoji->setFightsWon(0); + + // On récupère une instance de Rarity existante (par exemple, la première) + $rarity = $this->getRarity(); + if (!$rarity) { + throw new \RuntimeException('Aucun objet Rarity trouvé en base.'); + } + $emoji->setRarity($rarity); + + // Optionnel : définir parent1 et parent2 si tu veux tester avec des relations + // $emoji->setParent1(null); + // $emoji->setParent2(null); + + $entityManager->persist($emoji); + $entityManager->flush(); + + return new Response(); + } + private function getRarity(): Rarity { $rarity = $this->rarityRepository->findAll(); $rand = mt_rand() / mt_getrandmax();