From 432d7ba4dec8c437a0fb550fe0e3869a301fdfb1 Mon Sep 17 00:00:00 2001 From: bourgoino Date: Thu, 28 Nov 2024 16:58:42 +0100 Subject: [PATCH] laisse la --- src/Controller/DegreeController.php | 5 +++- src/Entity/Company.php | 2 +- templates/announcement/list.html.twig | 14 ++++++++---- templates/degree/show.html.twig | 33 ++++++++++++++++++--------- 4 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/Controller/DegreeController.php b/src/Controller/DegreeController.php index d7d54e0..90cebd4 100644 --- a/src/Controller/DegreeController.php +++ b/src/Controller/DegreeController.php @@ -71,11 +71,14 @@ final class DegreeController extends AbstractController #[Route('/{id}', name: 'app_degree_delete', methods: ['POST'])] public function delete(Request $request, Degree $degree, EntityManagerInterface $entityManager): Response { - if ($this->isCsrfTokenValid('delete'.$degree->getId(), $request->getPayload()->getString('_token'))) { + // Vérification du token CSRF pour la sécurité + if ($this->isCsrfTokenValid('delete'.$degree->getId(), $request->request->get('_token'))) { + // Suppression du diplôme $entityManager->remove($degree); $entityManager->flush(); } return $this->redirectToRoute('app_degree_index', [], Response::HTTP_SEE_OTHER); } + } diff --git a/src/Entity/Company.php b/src/Entity/Company.php index ae8ccaa..1a3bd2f 100644 --- a/src/Entity/Company.php +++ b/src/Entity/Company.php @@ -62,7 +62,7 @@ class Company return $this; } - public function getAddress(): ?string + public function getAddress(): ?stringz { return $this->address; } diff --git a/templates/announcement/list.html.twig b/templates/announcement/list.html.twig index 541caaa..737f0f4 100644 --- a/templates/announcement/list.html.twig +++ b/templates/announcement/list.html.twig @@ -3,12 +3,18 @@ {% block title %}Bienvenue sur Hegreshpere{% endblock %} {% block body %} +

Liste des annonces

+ +
+ {% for ann in announcements %}

{{ ann.title }}

{{ ann.company.name }}

@@ -17,6 +23,4 @@

{{ ann.creationDate|date("d-m-y") }}

{% endfor %} - - -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/templates/degree/show.html.twig b/templates/degree/show.html.twig index fd86e8d..41d349d 100644 --- a/templates/degree/show.html.twig +++ b/templates/degree/show.html.twig @@ -1,26 +1,37 @@ {% extends 'base.html.twig' %} -{% block title %}Degree{% endblock %} +{% block title %}Degrees{% endblock %} {% block body %} -

Degree

+

List of Degrees

+ + + + + + + + {% for degree in degrees %} - - - - + + {% endfor %}
IdLabelActions
Id {{ degree.id }}
Label {{ degree.label }} + View + Edit + +
+ + + +
+
- back to list - - edit - - {{ include('degree/_delete_form.html.twig') }} + Add New Degree {% endblock %}