diff --git a/.env b/.env index 9fdb8fa..3666c82 100644 --- a/.env +++ b/.env @@ -32,9 +32,8 @@ DEFAULT_URI=http://localhost # DATABASE_URL="sqlite:///%kernel.project_dir%/var/data_%kernel.environment%.db" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4" # DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4" -DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8" +DATABASE_URL="mysql://contrib_root:123abc@127.0.0.1:3306/contrib?serverVersion=8.0.32&charset=utf8mb4" ###< doctrine/doctrine-bundle ### - ###> symfony/messenger ### # Choose one of the transports below # MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages diff --git a/info.txt b/info.txt new file mode 100644 index 0000000..45172ca Binary files /dev/null and b/info.txt differ diff --git a/src/Controller/BaseController.php b/src/Controller/BaseController.php new file mode 100644 index 0000000..d22a477 --- /dev/null +++ b/src/Controller/BaseController.php @@ -0,0 +1,25 @@ +render($template, [ + 'controller_name' => $controllerName, + 'msg' => $msg, + 'tableau' => $data, + ]); + } +} \ No newline at end of file diff --git a/src/Controller/CoucouController.php b/src/Controller/CoucouController.php new file mode 100644 index 0000000..86cec68 --- /dev/null +++ b/src/Controller/CoucouController.php @@ -0,0 +1,29 @@ + 'Colaboration', + 'prenom' => 'Equipe', + ]; + + return $this->renderWithData('coucou/Coucou.html.twig', + 'Faite du Sport', + 'Bien venu !', + $tab + ); + } +} diff --git a/src/Controller/DroitController.php b/src/Controller/DroitController.php new file mode 100644 index 0000000..31403a1 --- /dev/null +++ b/src/Controller/DroitController.php @@ -0,0 +1,84 @@ +getRepository(Droit::class) + ->findAll(); + + return $this->render('droit/index.html.twig', [ + 'droits' => $droits, + ]); + } + + #[Route('/new', name: 'app_droit_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $droit = new Droit(); + $form = $this->createForm(DroitType::class, $droit); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($droit); + $entityManager->flush(); + + return $this->redirectToRoute('app_droit_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('droit/new.html.twig', [ + 'droit' => $droit, + 'form' => $form, + ]); + } + + #[Route('/{idDroit}', name: 'app_droit_show', methods: ['GET'])] + public function show(Droit $droit): Response + { + return $this->render('droit/show.html.twig', [ + 'droit' => $droit, + ]); + } + + #[Route('/{idDroit}/edit', name: 'app_droit_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Droit $droit, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(DroitType::class, $droit); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_droit_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('droit/edit.html.twig', [ + 'droit' => $droit, + 'form' => $form, + ]); + } + + #[Route('/{idDroit}', name: 'app_droit_delete', methods: ['POST'])] + public function delete(Request $request, Droit $droit, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$droit->getIdDroit(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($droit); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_droit_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Controller/MembreController.php b/src/Controller/MembreController.php new file mode 100644 index 0000000..c16957c --- /dev/null +++ b/src/Controller/MembreController.php @@ -0,0 +1,84 @@ +getRepository(Membre::class) + ->findAll(); + + return $this->render('membre/index.html.twig', [ + 'membres' => $membres, + ]); + } + + #[Route('/new', name: 'app_membre_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $membre = new Membre(); + $form = $this->createForm(MembreType::class, $membre); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($membre); + $entityManager->flush(); + + return $this->redirectToRoute('app_membre_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('membre/new.html.twig', [ + 'membre' => $membre, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_membre_show', methods: ['GET'])] + public function show(Membre $membre): Response + { + return $this->render('membre/show.html.twig', [ + 'membre' => $membre, + ]); + } + + #[Route('/{id}/edit', name: 'app_membre_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Membre $membre, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(MembreType::class, $membre); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_membre_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('membre/edit.html.twig', [ + 'membre' => $membre, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_membre_delete', methods: ['POST'])] + public function delete(Request $request, Membre $membre, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$membre->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($membre); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_membre_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Controller/OController.php b/src/Controller/OController.php new file mode 100644 index 0000000..6ba1df2 --- /dev/null +++ b/src/Controller/OController.php @@ -0,0 +1,84 @@ +getRepository(Membre::class) + ->findAll(); + + return $this->render('o/index.html.twig', [ + 'membres' => $membres, + ]); + } + + #[Route('/new', name: 'app_o_new', methods: ['GET', 'POST'])] + public function new(Request $request, EntityManagerInterface $entityManager): Response + { + $membre = new Membre(); + $form = $this->createForm(Membre1Type::class, $membre); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->persist($membre); + $entityManager->flush(); + + return $this->redirectToRoute('app_o_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('o/new.html.twig', [ + 'membre' => $membre, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_o_show', methods: ['GET'])] + public function show(Membre $membre): Response + { + return $this->render('o/show.html.twig', [ + 'membre' => $membre, + ]); + } + + #[Route('/{id}/edit', name: 'app_o_edit', methods: ['GET', 'POST'])] + public function edit(Request $request, Membre $membre, EntityManagerInterface $entityManager): Response + { + $form = $this->createForm(Membre1Type::class, $membre); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $entityManager->flush(); + + return $this->redirectToRoute('app_o_index', [], Response::HTTP_SEE_OTHER); + } + + return $this->render('o/edit.html.twig', [ + 'membre' => $membre, + 'form' => $form, + ]); + } + + #[Route('/{id}', name: 'app_o_delete', methods: ['POST'])] + public function delete(Request $request, Membre $membre, EntityManagerInterface $entityManager): Response + { + if ($this->isCsrfTokenValid('delete'.$membre->getId(), $request->getPayload()->getString('_token'))) { + $entityManager->remove($membre); + $entityManager->flush(); + } + + return $this->redirectToRoute('app_o_index', [], Response::HTTP_SEE_OTHER); + } +} diff --git a/src/Controller/PecheController.php b/src/Controller/PecheController.php new file mode 100644 index 0000000..41d1d91 --- /dev/null +++ b/src/Controller/PecheController.php @@ -0,0 +1,22 @@ +render('peche/index.html.twig', [ + 'controller_name' => 'PecheController', + ]); + } +} diff --git a/src/Controller/SportController.php b/src/Controller/SportController.php new file mode 100644 index 0000000..6946b34 --- /dev/null +++ b/src/Controller/SportController.php @@ -0,0 +1,29 @@ + 'Sport-Catégorie', + 'specialite' => 'Spécialisation', + ]; + + return $this->renderWithData('sport/sport.html.twig', + 'Faire du Sport', + 'Venez avec nous !', + $tab + ); + } +} \ No newline at end of file diff --git a/src/Entity/Droit.php b/src/Entity/Droit.php new file mode 100644 index 0000000..5640667 --- /dev/null +++ b/src/Entity/Droit.php @@ -0,0 +1,35 @@ +idDroit; + } + + public function getLibDroit(): ?string + { + return $this->libDroit; + } + + public function setLibDroit(string $libDroit): self + { + $this->libDroit = $libDroit; + return $this; + } +} diff --git a/src/Entity/Membre.php b/src/Entity/Membre.php new file mode 100644 index 0000000..f862d59 --- /dev/null +++ b/src/Entity/Membre.php @@ -0,0 +1,37 @@ +id; } + public function setId(string $id): self { $this->id = $id; return $this; } + + public function getNom(): ?string { return $this->nom; } + public function setNom(string $nom): self { $this->nom = $nom; return $this; } + + public function getPassword(): ?string { return $this->password; } + public function setPassword(?string $password): self { $this->password = $password; return $this; } + + public function getDroit(): ?Droit { return $this->droit; } + public function setDroit(?Droit $droit): self { $this->droit = $droit; return $this; } +} diff --git a/src/Form/DroitType.php b/src/Form/DroitType.php new file mode 100644 index 0000000..b683c94 --- /dev/null +++ b/src/Form/DroitType.php @@ -0,0 +1,25 @@ +add('libDroit') + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Droit::class, + ]); + } +} diff --git a/src/Form/Membre1Type.php b/src/Form/Membre1Type.php new file mode 100644 index 0000000..0bd8d45 --- /dev/null +++ b/src/Form/Membre1Type.php @@ -0,0 +1,33 @@ +add('id') + ->add('nom') + ->add('password') + ->add('droit', EntityType::class, [ + 'class' => Droit::class, + 'choice_label' => 'id', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Membre::class, + ]); + } +} diff --git a/src/Form/MembreType.php b/src/Form/MembreType.php new file mode 100644 index 0000000..650d9fd --- /dev/null +++ b/src/Form/MembreType.php @@ -0,0 +1,33 @@ +add('id') + ->add('nom') + ->add('password') + ->add('droit', EntityType::class, [ + 'class' => Droit::class, + 'choice_label' => 'id', + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Membre::class, + ]); + } +} diff --git a/src/Repository/MembreRepository.php b/src/Repository/MembreRepository.php new file mode 100644 index 0000000..6b5c497 --- /dev/null +++ b/src/Repository/MembreRepository.php @@ -0,0 +1,15 @@ + + + +
+
+
+

{{ controller_name }}

+ +

{{ msg }}

+ +
+ +

Tableau reçu :

+
    + {% for ligne in tableau %} +
  1. {{ ligne }}
  2. + {% endfor %} +
+ + + Aller sur Sport +
+
+
+ + + +{% endblock %} diff --git a/templates/droit/_delete_form.html.twig b/templates/droit/_delete_form.html.twig new file mode 100644 index 0000000..72f8f60 --- /dev/null +++ b/templates/droit/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/droit/_form.html.twig b/templates/droit/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/droit/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/droit/edit.html.twig b/templates/droit/edit.html.twig new file mode 100644 index 0000000..65b34b9 --- /dev/null +++ b/templates/droit/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Droit{% endblock %} + +{% block body %} +

Edit Droit

+ + {{ include('droit/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('droit/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/droit/index.html.twig b/templates/droit/index.html.twig new file mode 100644 index 0000000..97a79dd --- /dev/null +++ b/templates/droit/index.html.twig @@ -0,0 +1,35 @@ +{% extends 'base.html.twig' %} + +{% block title %}Droit index{% endblock %} + +{% block body %} +

Droit index

+ + + + + + + + + + + {% for droit in droits %} + + + + + + {% else %} + + + + {% endfor %} + +
IdDroitLibDroitactions
{{ droit.idDroit }}{{ droit.libDroit }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/droit/new.html.twig b/templates/droit/new.html.twig new file mode 100644 index 0000000..2d8e46d --- /dev/null +++ b/templates/droit/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Droit{% endblock %} + +{% block body %} +

Create new Droit

+ + {{ include('droit/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/droit/show.html.twig b/templates/droit/show.html.twig new file mode 100644 index 0000000..79b5940 --- /dev/null +++ b/templates/droit/show.html.twig @@ -0,0 +1,26 @@ +{% extends 'base.html.twig' %} + +{% block title %}Droit{% endblock %} + +{% block body %} +

Droit

+ + + + + + + + + + + + +
IdDroit{{ droit.idDroit }}
LibDroit{{ droit.libDroit }}
+ + back to list + + edit + + {{ include('droit/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/membre/_delete_form.html.twig b/templates/membre/_delete_form.html.twig new file mode 100644 index 0000000..ca0dc03 --- /dev/null +++ b/templates/membre/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/membre/_form.html.twig b/templates/membre/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/membre/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/membre/edit.html.twig b/templates/membre/edit.html.twig new file mode 100644 index 0000000..b0853ab --- /dev/null +++ b/templates/membre/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Membre{% endblock %} + +{% block body %} +

Edit Membre

+ + {{ include('membre/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('membre/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/membre/index.html.twig b/templates/membre/index.html.twig new file mode 100644 index 0000000..42c2c1b --- /dev/null +++ b/templates/membre/index.html.twig @@ -0,0 +1,45 @@ +{% extends 'base.html.twig' %} + +{% block title %}Membre index{% endblock %} + +{% block stylesheets %} + {{ parent() }} + {# Ajouter Bootstrap depuis le CDN #} + +{% endblock %} + +{% block body %} +
+

Membre index

+ + + + + + + + + + + + {% for membre in membres %} + + + + + + + {% else %} + + + + {% endfor %} + +
IdNomPasswordActions
{{ membre.id }}{{ membre.nom }}{{ membre.password }} + Show + Edit +
No records found
+ + Create new +
+{% endblock %} diff --git a/templates/membre/membre.html.twig b/templates/membre/membre.html.twig new file mode 100644 index 0000000..08bc696 --- /dev/null +++ b/templates/membre/membre.html.twig @@ -0,0 +1,22 @@ +{# templates/membre/index.html.twig #} + +

Liste des Membres

+ + + + + + + + + + + {% for membre in membres %} + + + + + + {% endfor %} + +
IDNomDroit
{{ membre.id }}{{ membre.nom }}{{ membre.droit ? membre.droit.nom : 'Aucun' }}
\ No newline at end of file diff --git a/templates/membre/new.html.twig b/templates/membre/new.html.twig new file mode 100644 index 0000000..fb021c6 --- /dev/null +++ b/templates/membre/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Membre{% endblock %} + +{% block body %} +

Create new Membre

+ + {{ include('membre/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/membre/show.html.twig b/templates/membre/show.html.twig new file mode 100644 index 0000000..c88e2b0 --- /dev/null +++ b/templates/membre/show.html.twig @@ -0,0 +1,30 @@ +{% extends 'base.html.twig' %} + +{% block title %}Membre{% endblock %} + +{% block body %} +

Membre

+ + + + + + + + + + + + + + + + +
Id{{ membre.id }}
Nom{{ membre.nom }}
Password{{ membre.password }}
+ + back to list + + edit + + {{ include('membre/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/o/_delete_form.html.twig b/templates/o/_delete_form.html.twig new file mode 100644 index 0000000..e0bff79 --- /dev/null +++ b/templates/o/_delete_form.html.twig @@ -0,0 +1,4 @@ +
+ + +
diff --git a/templates/o/_form.html.twig b/templates/o/_form.html.twig new file mode 100644 index 0000000..bf20b98 --- /dev/null +++ b/templates/o/_form.html.twig @@ -0,0 +1,4 @@ +{{ form_start(form) }} + {{ form_widget(form) }} + +{{ form_end(form) }} diff --git a/templates/o/edit.html.twig b/templates/o/edit.html.twig new file mode 100644 index 0000000..351be98 --- /dev/null +++ b/templates/o/edit.html.twig @@ -0,0 +1,13 @@ +{% extends 'base.html.twig' %} + +{% block title %}Edit Membre{% endblock %} + +{% block body %} +

Edit Membre

+ + {{ include('o/_form.html.twig', {'button_label': 'Update'}) }} + + back to list + + {{ include('o/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/o/index.html.twig b/templates/o/index.html.twig new file mode 100644 index 0000000..76e558a --- /dev/null +++ b/templates/o/index.html.twig @@ -0,0 +1,37 @@ +{% extends 'base.html.twig' %} + +{% block title %}Membre index{% endblock %} + +{% block body %} +

Membre index

+ + + + + + + + + + + + {% for membre in membres %} + + + + + + + {% else %} + + + + {% endfor %} + +
IdNomPasswordactions
{{ membre.id }}{{ membre.nom }}{{ membre.password }} + show + edit +
no records found
+ + Create new +{% endblock %} diff --git a/templates/o/new.html.twig b/templates/o/new.html.twig new file mode 100644 index 0000000..4ad81e5 --- /dev/null +++ b/templates/o/new.html.twig @@ -0,0 +1,11 @@ +{% extends 'base.html.twig' %} + +{% block title %}New Membre{% endblock %} + +{% block body %} +

Create new Membre

+ + {{ include('o/_form.html.twig') }} + + back to list +{% endblock %} diff --git a/templates/o/show.html.twig b/templates/o/show.html.twig new file mode 100644 index 0000000..9e8f8f9 --- /dev/null +++ b/templates/o/show.html.twig @@ -0,0 +1,30 @@ +{% extends 'base.html.twig' %} + +{% block title %}Membre{% endblock %} + +{% block body %} +

Membre

+ + + + + + + + + + + + + + + + +
Id{{ membre.id }}
Nom{{ membre.nom }}
Password{{ membre.password }}
+ + back to list + + edit + + {{ include('o/_delete_form.html.twig') }} +{% endblock %} diff --git a/templates/peche/index.html.twig b/templates/peche/index.html.twig new file mode 100644 index 0000000..20274e7 --- /dev/null +++ b/templates/peche/index.html.twig @@ -0,0 +1,14 @@ +{% extends 'base.html.twig' %} + +{% block title %}Hello PecheController!{% endblock %} + +{% block body %} + + +
+

Hello {{ controller_name }}! ✅

+
+{% endblock %} diff --git a/templates/sport/sport.html.twig b/templates/sport/sport.html.twig new file mode 100644 index 0000000..d8ed2e3 --- /dev/null +++ b/templates/sport/sport.html.twig @@ -0,0 +1,33 @@ +{% extends 'base.html.twig' %} + +{% block title %}Go Sport!{% endblock %} + +{% block body %} + + + +
+
+
+

{{ controller_name }}

+ +

{{ msg }}

+ +
+ +

Tableau Sport :

+
    + {% for ligne in tableau %} +
  1. {{ ligne }}
  2. + {% endfor %} +
+ + + Retourner sur Coucou +
+
+
+ + + +{% endblock %} \ No newline at end of file diff --git a/tests/Controller/PecheControllerTest.php b/tests/Controller/PecheControllerTest.php new file mode 100644 index 0000000..04c3338 --- /dev/null +++ b/tests/Controller/PecheControllerTest.php @@ -0,0 +1,16 @@ +request('GET', '/peche'); + + self::assertResponseIsSuccessful(); + } +}