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 @@
Term | Actions |
---|---|
+ + | ++ | + +