connexion base et création premier crud
This commit is contained in:
3
.env
3
.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
|
||||
|
||||
25
src/Controller/BaseController.php
Normal file
25
src/Controller/BaseController.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Implémente des fonctions de class "fontion répétitives"
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
abstract class BaseController extends AbstractController
|
||||
{
|
||||
protected function renderWithData(string $template,
|
||||
string $controllerName, string $msg,
|
||||
array $data): Response
|
||||
{
|
||||
return $this->render($template, [
|
||||
'controller_name' => $controllerName,
|
||||
'msg' => $msg,
|
||||
'tableau' => $data,
|
||||
]);
|
||||
}
|
||||
}
|
||||
29
src/Controller/CoucouController.php
Normal file
29
src/Controller/CoucouController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Affiche la page "Coucou"
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class CoucouController extends BaseController
|
||||
{
|
||||
#[Route('/coucou', name: 'app_coucou')]
|
||||
public function index(): Response
|
||||
{
|
||||
$tab = [
|
||||
'nom' => 'Colaboration',
|
||||
'prenom' => 'Equipe',
|
||||
];
|
||||
|
||||
return $this->renderWithData('coucou/Coucou.html.twig',
|
||||
'Faite du Sport',
|
||||
'Bien venu !',
|
||||
$tab
|
||||
);
|
||||
}
|
||||
}
|
||||
84
src/Controller/DroitController.php
Normal file
84
src/Controller/DroitController.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Droit;
|
||||
use App\Form\DroitType;
|
||||
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('/droit')]
|
||||
final class DroitController extends AbstractController
|
||||
{
|
||||
#[Route(name: 'app_droit_index', methods: ['GET'])]
|
||||
public function index(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$droits = $entityManager
|
||||
->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);
|
||||
}
|
||||
}
|
||||
84
src/Controller/MembreController.php
Normal file
84
src/Controller/MembreController.php
Normal 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);
|
||||
}
|
||||
}
|
||||
84
src/Controller/OController.php
Normal file
84
src/Controller/OController.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use App\Entity\Membre;
|
||||
use App\Form\Membre1Type;
|
||||
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('/o')]
|
||||
final class OController extends AbstractController
|
||||
{
|
||||
#[Route(name: 'app_o_index', methods: ['GET'])]
|
||||
public function index(EntityManagerInterface $entityManager): Response
|
||||
{
|
||||
$membres = $entityManager
|
||||
->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);
|
||||
}
|
||||
}
|
||||
22
src/Controller/PecheController.php
Normal file
22
src/Controller/PecheController.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
/**
|
||||
* Affiche la page "Peche"
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class PecheController extends BaseController
|
||||
{
|
||||
#[Route('/peche', name: 'app_peche')]
|
||||
public function index(): Response
|
||||
{
|
||||
return $this->render('peche/index.html.twig', [
|
||||
'controller_name' => 'PecheController',
|
||||
]);
|
||||
}
|
||||
}
|
||||
29
src/Controller/SportController.php
Normal file
29
src/Controller/SportController.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Affiche la page "Sport"
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Attribute\Route;
|
||||
|
||||
final class SportController extends BaseController
|
||||
{
|
||||
#[Route('/sport', name: 'app_sport')]
|
||||
public function sport(): Response
|
||||
{
|
||||
$tab = [
|
||||
'categorie' => 'Sport-Catégorie',
|
||||
'specialite' => 'Spécialisation',
|
||||
];
|
||||
|
||||
return $this->renderWithData('sport/sport.html.twig',
|
||||
'Faire du Sport',
|
||||
'Venez avec nous !',
|
||||
$tab
|
||||
);
|
||||
}
|
||||
}
|
||||
35
src/Entity/Droit.php
Normal file
35
src/Entity/Droit.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
// src/Entity/Droit.php
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: "Droit")]
|
||||
class Droit
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: "integer", name: "idDroit")]
|
||||
private ?int $idDroit = null;
|
||||
|
||||
#[ORM\Column(type: "string", length: 30, name: "LibDroit")]
|
||||
private ?string $libDroit = null;
|
||||
|
||||
// Getter et Setter
|
||||
public function getIdDroit(): ?int
|
||||
{
|
||||
return $this->idDroit;
|
||||
}
|
||||
|
||||
public function getLibDroit(): ?string
|
||||
{
|
||||
return $this->libDroit;
|
||||
}
|
||||
|
||||
public function setLibDroit(string $libDroit): self
|
||||
{
|
||||
$this->libDroit = $libDroit;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
37
src/Entity/Membre.php
Normal file
37
src/Entity/Membre.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
// src/Entity/Membre.php
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: "Membre")]
|
||||
class Membre
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\Column(type: "string", length: 20)]
|
||||
private ?string $id = null;
|
||||
|
||||
#[ORM\Column(type: "string", length: 50)]
|
||||
private ?string $nom = null;
|
||||
|
||||
#[ORM\Column(type: "string", length: 100, nullable: true)]
|
||||
private ?string $password = null;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: Droit::class)]
|
||||
#[ORM\JoinColumn(name: "droit_id", referencedColumnName: "idDroit", nullable: true, onDelete: "SET NULL")]
|
||||
private ?Droit $droit = null;
|
||||
|
||||
// Getters et setters
|
||||
public function getId(): ?string { return $this->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; }
|
||||
}
|
||||
25
src/Form/DroitType.php
Normal file
25
src/Form/DroitType.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Droit;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class DroitType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->add('libDroit')
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Droit::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
src/Form/Membre1Type.php
Normal file
33
src/Form/Membre1Type.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Droit;
|
||||
use App\Entity\Membre;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class Membre1Type extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
src/Form/MembreType.php
Normal file
33
src/Form/MembreType.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Form;
|
||||
|
||||
use App\Entity\Droit;
|
||||
use App\Entity\Membre;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class MembreType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
$builder
|
||||
->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
15
src/Repository/MembreRepository.php
Normal file
15
src/Repository/MembreRepository.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
// src/Repository/MembreRepository.php
|
||||
namespace App\Repository;
|
||||
|
||||
use App\Entity\Membre;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
|
||||
class MembreRepository extends ServiceEntityRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
{
|
||||
parent::__construct($registry, Membre::class);
|
||||
}
|
||||
}
|
||||
33
templates/coucou/Coucou.html.twig
Normal file
33
templates/coucou/Coucou.html.twig
Normal file
@@ -0,0 +1,33 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello CoucouController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<!-- Ajout de Bootstrap via CDN -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<div class="container my-5">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h1 class="card-title text-primary mb-4">{{ controller_name }} </h1>
|
||||
|
||||
<h3 class="text-secondary">{{ msg }}</h3>
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>Tableau reçu :</h4>
|
||||
<ol class="list-group list-group-numbered mb-4">
|
||||
{% for ligne in tableau %}
|
||||
<li class="list-group-item">{{ ligne }}</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
|
||||
<!-- Bouton vers la page Sport -->
|
||||
<a href="{{ path('app_sport') }}" class="btn btn-success btn-lg">Aller sur Sport</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Optionnel : JS Bootstrap pour composants interactifs -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% endblock %}
|
||||
4
templates/droit/_delete_form.html.twig
Normal file
4
templates/droit/_delete_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
<form method="post" action="{{ path('app_droit_delete', {'idDroit': droit.idDroit}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ droit.idDroit) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
templates/droit/_form.html.twig
Normal file
4
templates/droit/_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
13
templates/droit/edit.html.twig
Normal file
13
templates/droit/edit.html.twig
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit Droit{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Droit</h1>
|
||||
|
||||
{{ include('droit/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('app_droit_index') }}">back to list</a>
|
||||
|
||||
{{ include('droit/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
35
templates/droit/index.html.twig
Normal file
35
templates/droit/index.html.twig
Normal file
@@ -0,0 +1,35 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Droit index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Droit index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IdDroit</th>
|
||||
<th>LibDroit</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for droit in droits %}
|
||||
<tr>
|
||||
<td>{{ droit.idDroit }}</td>
|
||||
<td>{{ droit.libDroit }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_droit_show', {'idDroit': droit.idDroit}) }}">show</a>
|
||||
<a href="{{ path('app_droit_edit', {'idDroit': droit.idDroit}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="3">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_droit_new') }}">Create new</a>
|
||||
{% endblock %}
|
||||
11
templates/droit/new.html.twig
Normal file
11
templates/droit/new.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Droit{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Droit</h1>
|
||||
|
||||
{{ include('droit/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_droit_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
26
templates/droit/show.html.twig
Normal file
26
templates/droit/show.html.twig
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Droit{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Droit</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>IdDroit</th>
|
||||
<td>{{ droit.idDroit }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>LibDroit</th>
|
||||
<td>{{ droit.libDroit }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_droit_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_droit_edit', {'idDroit': droit.idDroit}) }}">edit</a>
|
||||
|
||||
{{ include('droit/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
4
templates/membre/_delete_form.html.twig
Normal file
4
templates/membre/_delete_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
<form method="post" action="{{ path('app_membre_delete', {'id': membre.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ membre.id) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
templates/membre/_form.html.twig
Normal file
4
templates/membre/_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
13
templates/membre/edit.html.twig
Normal file
13
templates/membre/edit.html.twig
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit Membre{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Membre</h1>
|
||||
|
||||
{{ include('membre/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('app_membre_index') }}">back to list</a>
|
||||
|
||||
{{ include('membre/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
45
templates/membre/index.html.twig
Normal file
45
templates/membre/index.html.twig
Normal file
@@ -0,0 +1,45 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Membre index{% endblock %}
|
||||
|
||||
{% block stylesheets %}
|
||||
{{ parent() }}
|
||||
{# Ajouter Bootstrap depuis le CDN #}
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<div class="container mt-4">
|
||||
<h1 class="mb-4">Membre index</h1>
|
||||
|
||||
<table class="table table-striped table-bordered">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Nom</th>
|
||||
<th>Password</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for membre in membres %}
|
||||
<tr>
|
||||
<td>{{ membre.id }}</td>
|
||||
<td>{{ membre.nom }}</td>
|
||||
<td>{{ membre.password }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_membre_show', {'id': membre.id}) }}" class="btn btn-sm btn-primary">Show</a>
|
||||
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}" class="btn btn-sm btn-warning">Edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center">No records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_membre_new') }}" class="btn btn-success">Create new</a>
|
||||
</div>
|
||||
{% endblock %}
|
||||
22
templates/membre/membre.html.twig
Normal file
22
templates/membre/membre.html.twig
Normal file
@@ -0,0 +1,22 @@
|
||||
{# templates/membre/index.html.twig #}
|
||||
|
||||
<h1>Liste des Membres</h1>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nom</th>
|
||||
<th>Droit</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for membre in membres %}
|
||||
<tr>
|
||||
<td>{{ membre.id }}</td>
|
||||
<td>{{ membre.nom }}</td>
|
||||
<td>{{ membre.droit ? membre.droit.nom : 'Aucun' }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
11
templates/membre/new.html.twig
Normal file
11
templates/membre/new.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Membre{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Membre</h1>
|
||||
|
||||
{{ include('membre/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_membre_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
30
templates/membre/show.html.twig
Normal file
30
templates/membre/show.html.twig
Normal file
@@ -0,0 +1,30 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Membre{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Membre</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ membre.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<td>{{ membre.nom }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Password</th>
|
||||
<td>{{ membre.password }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_membre_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_membre_edit', {'id': membre.id}) }}">edit</a>
|
||||
|
||||
{{ include('membre/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
4
templates/o/_delete_form.html.twig
Normal file
4
templates/o/_delete_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
<form method="post" action="{{ path('app_o_delete', {'id': membre.id}) }}" onsubmit="return confirm('Are you sure you want to delete this item?');">
|
||||
<input type="hidden" name="_token" value="{{ csrf_token('delete' ~ membre.id) }}">
|
||||
<button class="btn">Delete</button>
|
||||
</form>
|
||||
4
templates/o/_form.html.twig
Normal file
4
templates/o/_form.html.twig
Normal file
@@ -0,0 +1,4 @@
|
||||
{{ form_start(form) }}
|
||||
{{ form_widget(form) }}
|
||||
<button class="btn">{{ button_label|default('Save') }}</button>
|
||||
{{ form_end(form) }}
|
||||
13
templates/o/edit.html.twig
Normal file
13
templates/o/edit.html.twig
Normal file
@@ -0,0 +1,13 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Edit Membre{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Edit Membre</h1>
|
||||
|
||||
{{ include('o/_form.html.twig', {'button_label': 'Update'}) }}
|
||||
|
||||
<a href="{{ path('app_o_index') }}">back to list</a>
|
||||
|
||||
{{ include('o/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
37
templates/o/index.html.twig
Normal file
37
templates/o/index.html.twig
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Membre index{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Membre index</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<th>Nom</th>
|
||||
<th>Password</th>
|
||||
<th>actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for membre in membres %}
|
||||
<tr>
|
||||
<td>{{ membre.id }}</td>
|
||||
<td>{{ membre.nom }}</td>
|
||||
<td>{{ membre.password }}</td>
|
||||
<td>
|
||||
<a href="{{ path('app_o_show', {'id': membre.id}) }}">show</a>
|
||||
<a href="{{ path('app_o_edit', {'id': membre.id}) }}">edit</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4">no records found</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_o_new') }}">Create new</a>
|
||||
{% endblock %}
|
||||
11
templates/o/new.html.twig
Normal file
11
templates/o/new.html.twig
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}New Membre{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Create new Membre</h1>
|
||||
|
||||
{{ include('o/_form.html.twig') }}
|
||||
|
||||
<a href="{{ path('app_o_index') }}">back to list</a>
|
||||
{% endblock %}
|
||||
30
templates/o/show.html.twig
Normal file
30
templates/o/show.html.twig
Normal file
@@ -0,0 +1,30 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Membre{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>Membre</h1>
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th>Id</th>
|
||||
<td>{{ membre.id }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Nom</th>
|
||||
<td>{{ membre.nom }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Password</th>
|
||||
<td>{{ membre.password }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<a href="{{ path('app_o_index') }}">back to list</a>
|
||||
|
||||
<a href="{{ path('app_o_edit', {'id': membre.id}) }}">edit</a>
|
||||
|
||||
{{ include('o/_delete_form.html.twig') }}
|
||||
{% endblock %}
|
||||
14
templates/peche/index.html.twig
Normal file
14
templates/peche/index.html.twig
Normal file
@@ -0,0 +1,14 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Hello PecheController!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<style>
|
||||
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
|
||||
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
|
||||
</style>
|
||||
|
||||
<div class="example-wrapper">
|
||||
<h1>Hello {{ controller_name }}! ✅</h1>
|
||||
</div>
|
||||
{% endblock %}
|
||||
33
templates/sport/sport.html.twig
Normal file
33
templates/sport/sport.html.twig
Normal file
@@ -0,0 +1,33 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block title %}Go Sport!{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<!-- Ajout de Bootstrap via CDN -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<div class="container my-5">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h1 class="card-title text-primary mb-4">{{ controller_name }}</h1>
|
||||
|
||||
<h3 class="text-secondary">{{ msg }}</h3>
|
||||
|
||||
<hr>
|
||||
|
||||
<h4>Tableau Sport :</h4>
|
||||
<ol class="list-group list-group-numbered mb-4">
|
||||
{% for ligne in tableau %}
|
||||
<li class="list-group-item">{{ ligne }}</li>
|
||||
{% endfor %}
|
||||
</ol>
|
||||
|
||||
<!-- Bouton pour revenir à Coucou -->
|
||||
<a href="{{ path('app_coucou') }}" class="btn btn-primary btn-lg">Retourner sur Coucou</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Optionnel : JS Bootstrap pour composants interactifs -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"></script>
|
||||
{% endblock %}
|
||||
16
tests/Controller/PecheControllerTest.php
Normal file
16
tests/Controller/PecheControllerTest.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
|
||||
final class PecheControllerTest extends WebTestCase
|
||||
{
|
||||
public function testIndex(): void
|
||||
{
|
||||
$client = static::createClient();
|
||||
$client->request('GET', '/peche');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user