diff --git a/src/Controller/HeadwordController.php b/src/Controller/HeadwordController.php index 2b7cc974b6bca8e0a7b3a06d6fe0235a9ae38252..15eeecc231d4720ae4c2db5cec6748b1aa27e15e 100644 --- a/src/Controller/HeadwordController.php +++ b/src/Controller/HeadwordController.php @@ -62,7 +62,13 @@ class HeadwordController extends AppBaseController return new JsonResponse($this->generateUrl('app_entry_show', ['id' => $entries[0]->getId()]), 211); } elseif ($wiktionaryManager->search($search, $this->getLanguage())) { - $headword = $this->newHeadword($search, $this->getLanguage()); + $headword = $this->em->getRepository(Headword::class)->findOneBy([ + 'value' => $search, + 'language' => $this->getLanguage(), + ]); + if (!$headword) { + $headword = $this->newHeadword($search, $this->getLanguage()); + } $entry = $this->getOrCreateEntryInZeroLexicon($headword); $this->em->flush(); $this->addFlash('success', "« " . $search . " » a été ajouté à Balex depuis le wiktionnaire"); @@ -70,8 +76,8 @@ class HeadwordController extends AppBaseController return new JsonResponse($this->generateUrl('app_entry_show', ['id' => $entry->getId()]), 211); } else { - return $this->render("headword/confirmAddNewWord.html.twig", ['word' => $search]); - } + return $this->render("headword/confirmAddNewWord.html.twig", ['word' => $search]); + } } /** @@ -80,7 +86,13 @@ class HeadwordController extends AppBaseController public function confirmNewWordCreation(Request $request): Response { $word = $request->get('word'); - $headword = $this->newHeadword($word, $this->getLanguage()); + $headword = $this->em->getRepository(Headword::class)->findOneBy([ + 'value' => $word, + 'language' => $this->getLanguage(), + ]); + if (!$headword) { + $headword = $this->newHeadword($word, $this->getLanguage()); + } $this->createEntryInNewWordsLexicon($headword); $this->em->flush(); diff --git a/templates/entry/_entryAttributes.html.twig b/templates/entry/_entryAttributes.html.twig index 52ebc58b949f6f386b9c1266f986ff3bff3d3455..313d013f06e9d581d062067737d186252bce861c 100644 --- a/templates/entry/_entryAttributes.html.twig +++ b/templates/entry/_entryAttributes.html.twig @@ -40,7 +40,7 @@ {% set pronunciationKey = '[Items][0][Sense][Pronunciations]['~key~']' %} <li id="{{ pronunciation.id }}"> - <div class="links-container"> + <div class="links-container pb-1"> {% if pronunciation.accent is defined %}{{ pronunciation.accent }} :{% endif %} {{ pronunciation.api }} {% for sound in pronunciation.sounds|default([]) %}