Skip to content
Snippets Groups Projects
Commit 34f17a13 authored by Pierre Fleutot's avatar Pierre Fleutot
Browse files

Fix on vérifie qu'on a pas déjà un headword avant de le créer quand on crée...

Fix on vérifie qu'on a pas déjà un headword avant de le créer quand on crée une entrée depuis la searchbar
parent 3170a092
No related merge requests found
......@@ -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();
......
......@@ -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([]) %}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment