first commit

This commit is contained in:
BRAMAS Arthur
2025-10-13 17:26:15 +02:00
commit 02765a025e
89 changed files with 12240 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<?php
namespace App\Controller;
use App\Entity\Membre;
use App\Form\MembreType;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
#[Route('/membre')]
final class MembreController extends AbstractController
{
#[Route(name: 'app_membre_index', methods: ['GET'])]
public function index(EntityManagerInterface $entityManager): Response
{
$membres = $entityManager
->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);
}
}