From a5b706967929fe929e5f11f50653f2e799bfb4b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Wed, 30 Oct 2024 22:13:57 +0100 Subject: [PATCH] Stupid vocab term update --- src/Controller/VocabFuncContextController.php | 17 ++++++++++ templates/vocab_func_context/index.html.twig | 34 +++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/src/Controller/VocabFuncContextController.php b/src/Controller/VocabFuncContextController.php index b323c2c..50c7c22 100644 --- a/src/Controller/VocabFuncContextController.php +++ b/src/Controller/VocabFuncContextController.php @@ -54,6 +54,23 @@ class VocabFuncContextController extends AbstractController return $this->redirectToRoute('app_vocab_func_context'); } + #[Route('/vocabs/functional_context/update', name: 'app_vocab_func_context_upd')] + public function updateTerm(Request $request, EntityManagerInterface $em): Response + { + $id = $request->getPayload()->get('_id'); + $newTerm = $request->getPayload()->get('_new_term'); + + $repo = $em->getRepository(VocabFuncContext::class); + $vocab = $repo->find($id); + $vocab->setTerm($newTerm); + $em->flush(); + + $this->addFlash('notice', 'Term updated successfully'); + + return $this->redirectToRoute('app_vocab_func_context'); + } + + #[Route('/vocabs/functional_context/del', name: 'app_vocab_func_context_del')] public function deleteTerm(Request $request, EntityManagerInterface $em): Response { diff --git a/templates/vocab_func_context/index.html.twig b/templates/vocab_func_context/index.html.twig index 564e8f0..7c8cb74 100644 --- a/templates/vocab_func_context/index.html.twig +++ b/templates/vocab_func_context/index.html.twig @@ -48,6 +48,12 @@ {% if is_granted('ROLE_ADMIN') or is_granted('ROLE_REVISOR') %}
+