From c20ec66f22e372ceb896962b709faf2e50c82f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Wed, 30 Oct 2024 10:26:25 +0100 Subject: [PATCH] Brutal vocabulary interaction (draft) --- src/Controller/VocabFuncContextController.php | 54 +++++++++++ src/Entity/VocabFuncContext.php | 37 ++++++++ src/Repository/VocabFuncContextRepository.php | 18 ++++ templates/data_entry.html.twig | 2 +- templates/vocab_func_context/index.html.twig | 95 +++++++++++++++++++ 5 files changed, 205 insertions(+), 1 deletion(-) create mode 100644 src/Controller/VocabFuncContextController.php create mode 100644 src/Entity/VocabFuncContext.php create mode 100644 src/Repository/VocabFuncContextRepository.php create mode 100644 templates/vocab_func_context/index.html.twig diff --git a/src/Controller/VocabFuncContextController.php b/src/Controller/VocabFuncContextController.php new file mode 100644 index 0000000..6ea7e5f --- /dev/null +++ b/src/Controller/VocabFuncContextController.php @@ -0,0 +1,54 @@ +getRepository(VocabFuncContext::class)->findBy([], ['term' => 'ASC']); + + return $this->render('vocab_func_context/index.html.twig', [ + 'controller_name' => 'VocabFuncContextController', + 'terms' => $terms, + ]); + } + + #[Route('/vocabs/functional_context/add', name: 'app_vocab_func_context_add')] + public function addTerm(Request $request, EntityManagerInterface $em): Response + { + $term = $request->getPayload()->get('_term'); + + $vocab = new VocabFuncContext; + $vocab->setTerm($term); + $em->persist($vocab); + $em->flush(); + + $this->addFlash('notice', 'Term added 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 + { + $id = $request->getPayload()->get('_id'); + $repo = $em->getRepository(VocabFuncContext::class); + $term = $repo->find($id); + $em->remove($term); + $em->flush(); + + $this->addFlash('notice', 'Term deleted successfully'); + + return $this->redirectToRoute('app_vocab_func_context'); + } +} diff --git a/src/Entity/VocabFuncContext.php b/src/Entity/VocabFuncContext.php new file mode 100644 index 0000000..710809f --- /dev/null +++ b/src/Entity/VocabFuncContext.php @@ -0,0 +1,37 @@ +id; + } + + public function getTerm(): ?string + { + return $this->term; + } + + public function setTerm(string $term): static + { + $this->term = $term; + + return $this; + } +} + diff --git a/src/Repository/VocabFuncContextRepository.php b/src/Repository/VocabFuncContextRepository.php new file mode 100644 index 0000000..e21b974 --- /dev/null +++ b/src/Repository/VocabFuncContextRepository.php @@ -0,0 +1,18 @@ + + */ +class VocabFuncContextRepository extends ServiceEntityRepository +{ + public function __construct(ManagerRegistry $registry) + { + parent::__construct($registry, VocabFuncContext::class); + } +} diff --git a/templates/data_entry.html.twig b/templates/data_entry.html.twig index b5688ee..c3efc8f 100644 --- a/templates/data_entry.html.twig +++ b/templates/data_entry.html.twig @@ -105,7 +105,7 @@
  • - + diff --git a/templates/vocab_func_context/index.html.twig b/templates/vocab_func_context/index.html.twig new file mode 100644 index 0000000..d866846 --- /dev/null +++ b/templates/vocab_func_context/index.html.twig @@ -0,0 +1,95 @@ +{% extends 'data_entry.html.twig' %} + +{% block title %}Vocab - Functional context | ArCOA{% endblock %} + +{% block rightpanel %} +
    +

    Edit vocabulary

    +

    Functional context

    + +
    + + + {% for message in app.flashes('notice') %} +
    +
    {{ message }}
    +
    + {% endfor %} +
    + +
    +
    + +
    +
    + +
    +
    +
    + +

    Terms in vocabulary

    + + + {% for term in terms %} + + + + + {% endfor %} +
    TermActions
    + + +
    + + +
    +
    + +
    +
    + +{% endblock %} \ No newline at end of file