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

Lemma devient Headword

parent c96b5901
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ namespace App\Controller; ...@@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\Entry; use App\Entity\Entry;
use App\Entity\Graphy; use App\Entity\Graphy;
use App\Entity\Lemma; use App\Entity\Headword;
use App\Entity\Lexicon; use App\Entity\Lexicon;
use App\Entity\User; use App\Entity\User;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
...@@ -47,8 +47,8 @@ class EntryController extends ApiBaseController ...@@ -47,8 +47,8 @@ class EntryController extends ApiBaseController
// //
// foreach ($dataEntry->getLexicons() as $lexicon) { // foreach ($dataEntry->getLexicons() as $lexicon) {
// $entry = new Entry(); // $entry = new Entry();
// $entry->setLemma($dataEntry->getLemma()); // $entry->setHeadword($dataEntry->getHeadword());
// $entry->setLanguage($dataEntry->getLemma()->getLanguage()); // $entry->setLanguage($dataEntry->getHeadword()->getLanguage());
// $entry->setLexicon($lexicon); // $entry->setLexicon($lexicon);
// $this->doctrine->getManager()->persist($entry); // $this->doctrine->getManager()->persist($entry);
// } // }
...@@ -106,7 +106,7 @@ class EntryController extends ApiBaseController ...@@ -106,7 +106,7 @@ class EntryController extends ApiBaseController
$entries = $this->doctrine->getRepository(Entry::class)->search($filter); $entries = $this->doctrine->getRepository(Entry::class)->search($filter);
$content = $serializer->serialize($entries, 'json', ['groups' => ["entry:read", "lemma:read", "lexicon:read"]]); $content = $serializer->serialize($entries, 'json', ['groups' => ["entry:read", "headword:read", "lexicon:read"]]);
return new JsonResponse($content, 200, [], true); return new JsonResponse($content, 200, [], true);
} }
...@@ -135,7 +135,7 @@ class EntryController extends ApiBaseController ...@@ -135,7 +135,7 @@ class EntryController extends ApiBaseController
*/ */
public function createEntry(Request $request, SerializerInterface $serializer): Response public function createEntry(Request $request, SerializerInterface $serializer): Response
{ {
// But: Créer une entrée à partir d'une graphie, intégrer l'entrée dans les lexiques demandés. Un lemme correspondant à la graphie doit exister. // But: Créer une entrée à partir d'une graphie, intégrer l'entrée dans les lexiques demandés. Un mot-vedette correspondant à la graphie doit exister.
$data = json_decode($request->getContent(), true); $data = json_decode($request->getContent(), true);
if (!$data) { if (!$data) {
return $this->createJsonResponse(401, ['error' => sprintf("Json non valide")]); return $this->createJsonResponse(401, ['error' => sprintf("Json non valide")]);
...@@ -144,21 +144,21 @@ class EntryController extends ApiBaseController ...@@ -144,21 +144,21 @@ class EntryController extends ApiBaseController
return $this->createJsonResponse(401, ['error' => sprintf("Veuillez fournir une valeur pour: %s", implode(', ', $missingFields))]); return $this->createJsonResponse(401, ['error' => sprintf("Veuillez fournir une valeur pour: %s", implode(', ', $missingFields))]);
} }
$search = $this->doctrine->getRepository(Lemma::class)->getByGraphyValue($data['graphy']); // Pb mousse et mousse on trouvera deux lemmes !!!! $search = $this->doctrine->getRepository(Headword::class)->getByGraphyValue($data['graphy']); // Pb mousse et mousse on trouvera deux mot-vedettes !!!!
if (!$search) { if (!$search) {
return $this->createJsonResponse(401, ['error' => sprintf("Pas de lemme trouvé pour cette graphie")]); return $this->createJsonResponse(401, ['error' => sprintf("Pas de mot-vedette trouvé pour cette graphie")]);
} else { } else {
$lemma = $search[0]; $headword = $search[0];
} }
$lexicons = $this->getLexicons($data['target_lex']); $lexicons = $this->getLexicons($data['target_lex']);
foreach ($lexicons as $lexicon) { foreach ($lexicons as $lexicon) {
$entry = new Entry(); $entry = new Entry();
$entry->setLemma($lemma); $entry->setHeadword($headword);
$entry->setLanguage($lemma->getLanguage()); $entry->setLanguage($headword->getLanguage());
$entry->setLexicon($lexicon); $entry->setLexicon($lexicon);
if (!$this->doctrine->getRepository(Entry::class)->findBy(['lexicon' => $lexicon, 'lemma' => $lemma])) { if (!$this->doctrine->getRepository(Entry::class)->findBy(['lexicon' => $lexicon, 'headword' => $headword])) {
$this->doctrine->getManager()->persist($entry); $this->doctrine->getManager()->persist($entry);
$this->success[] = sprintf("Entrée créée dans le lexique : %s.", $lexicon); $this->success[] = sprintf("Entrée créée dans le lexique : %s.", $lexicon);
} else { } else {
...@@ -199,7 +199,7 @@ class EntryController extends ApiBaseController ...@@ -199,7 +199,7 @@ class EntryController extends ApiBaseController
if ($entry === null) { if ($entry === null) {
return $this->createJsonResponse(401, ['error' => sprintf("Invalid Entry Id")]); return $this->createJsonResponse(401, ['error' => sprintf("Invalid Entry Id")]);
} }
$content = $serializer->serialize($entry, 'json', ['groups' => ["entry:read", "lemma:read", "lexicon:read"]]); $content = $serializer->serialize($entry, 'json', ['groups' => ["entry:read", "headword:read", "lexicon:read"]]);
return new JsonResponse($content, 200, [], true); return new JsonResponse($content, 200, [], true);
} }
......
...@@ -4,7 +4,7 @@ namespace App\Controller; ...@@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\Entry; use App\Entity\Entry;
use App\Entity\Graphy; use App\Entity\Graphy;
use App\Entity\Lemma; use App\Entity\Headword;
use App\Entity\Lexicon; use App\Entity\Lexicon;
use App\Entity\User; use App\Entity\User;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
...@@ -117,8 +117,8 @@ class GraphyController extends ApiBaseController ...@@ -117,8 +117,8 @@ class GraphyController extends ApiBaseController
if (!$graphy) { if (!$graphy) {
return $this->createJsonResponse(401, ['error' => sprintf("Pas de graphie trouvée pour cette valeur et cette langue")]); return $this->createJsonResponse(401, ['error' => sprintf("Pas de graphie trouvée pour cette valeur et cette langue")]);
} }
if (! $graphy->getLemmas()->isEmpty()) { if (! $graphy->getHeadwords()->isEmpty()) {
return $this->createJsonResponse(403, ['error' => sprintf("Impossible de supprimer cette graphie car elle est liée à des lemmes")]); return $this->createJsonResponse(403, ['error' => sprintf("Impossible de supprimer cette graphie car elle est liée à des mots-vedettes")]);
} }
$this->doctrine->getManager()->remove($graphy); $this->doctrine->getManager()->remove($graphy);
$this->doctrine->getManager()->flush(); $this->doctrine->getManager()->flush();
......
...@@ -4,7 +4,7 @@ namespace App\Controller; ...@@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\Entry; use App\Entity\Entry;
use App\Entity\Graphy; use App\Entity\Graphy;
use App\Entity\Lemma; use App\Entity\Headword;
use App\Entity\Lexicon; use App\Entity\Lexicon;
use App\Entity\User; use App\Entity\User;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
...@@ -20,14 +20,14 @@ use Nelmio\ApiDocBundle\Annotation\Model; ...@@ -20,14 +20,14 @@ use Nelmio\ApiDocBundle\Annotation\Model;
use Nelmio\ApiDocBundle\Annotation\Security; use Nelmio\ApiDocBundle\Annotation\Security;
/** /**
* @Route("/api/lemma") * @Route("/api/headword")
*/ */
class LemmaController extends ApiBaseController class HeadwordController extends ApiBaseController
{ {
/** /**
* *
* @Route("/create", name="create_lemma", methods={"POST"}) * @Route("/create", name="create_headword", methods={"POST"})
* *
* @OA\Response(response=200, description="success", @OA\JsonContent(type="string")) * @OA\Response(response=200, description="success", @OA\JsonContent(type="string"))
* @OA\Response(response=401, description="error", @OA\JsonContent(type="string")) * @OA\Response(response=401, description="error", @OA\JsonContent(type="string"))
...@@ -42,10 +42,10 @@ class LemmaController extends ApiBaseController ...@@ -42,10 +42,10 @@ class LemmaController extends ApiBaseController
* ) * )
* ) * )
* ) * )
* @OA\Tag(name="Lemmas") * @OA\Tag(name="Headwords")
* @Security(name="OAuth2") * @Security(name="OAuth2")
*/ */
public function createLemma(Request $request): Response public function createHeadword(Request $request): Response
{ {
$data = json_decode($request->getContent(), true); $data = json_decode($request->getContent(), true);
if (!$data) { if (!$data) {
...@@ -63,19 +63,19 @@ class LemmaController extends ApiBaseController ...@@ -63,19 +63,19 @@ class LemmaController extends ApiBaseController
return $this->createJsonResponse(401, ['error' => sprintf("Pas de graphie trouvée pour: %s", $data['graphy'])]); return $this->createJsonResponse(401, ['error' => sprintf("Pas de graphie trouvée pour: %s", $data['graphy'])]);
} }
$lemma = $this->doctrine->getRepository(Lemma::class)->findOneBy([ $headword = $this->doctrine->getRepository(Headword::class)->findOneBy([
'value' => $data['graphy'], 'value' => $data['graphy'],
'language' => $data['language'], 'language' => $data['language'],
]); ]);
if (! $lemma) { if (! $headword) {
$lemma = new Lemma(); $headword = new Headword();
$this->doctrine->getManager()->persist($lemma); $this->doctrine->getManager()->persist($headword);
$lemma->setValue($data['graphy']); $headword->setValue($data['graphy']);
$lemma->addGraphy($graphy); $headword->addGraphy($graphy);
$lemma->setLanguage($data['language']); $headword->setLanguage($data['language']);
$this->success[] = sprintf("Lemme %s créé pour la langue %s", $data['graphy'], $data['language']); $this->success[] = sprintf("Mot-vedette %s créé pour la langue %s", $data['graphy'], $data['language']);
} else { } else {
$this->success[] = sprintf("Le lemme %s existe déjà pour la langue %s", $data['graphy'], $data['language']); $this->success[] = sprintf("Le mot-vedette %s existe déjà pour la langue %s", $data['graphy'], $data['language']);
} }
$this->doctrine->getManager()->flush(); $this->doctrine->getManager()->flush();
...@@ -84,7 +84,7 @@ class LemmaController extends ApiBaseController ...@@ -84,7 +84,7 @@ class LemmaController extends ApiBaseController
} }
/** /**
* @Route("/remove", name="lemma_delete", methods={"DELETE"}) * @Route("/remove", name="headword_delete", methods={"DELETE"})
* *
* @OA\Response( * @OA\Response(
* response=200, * response=200,
...@@ -97,12 +97,12 @@ class LemmaController extends ApiBaseController ...@@ -97,12 +97,12 @@ class LemmaController extends ApiBaseController
* @OA\RequestBody( * @OA\RequestBody(
* required=true, * required=true,
* @OA\JsonContent( * @OA\JsonContent(
* @OA\Property(property="lemma", type="string"), * @OA\Property(property="headword", type="string"),
* @OA\Property(property="language", type="string") * @OA\Property(property="language", type="string")
* ) * )
* ) * )
* ) * )
* @OA\Tag(name="Lemmas") * @OA\Tag(name="Headwords")
* @Security(name="OAuth2") * @Security(name="OAuth2")
*/ */
public function delete(Request $request) public function delete(Request $request)
...@@ -111,25 +111,25 @@ class LemmaController extends ApiBaseController ...@@ -111,25 +111,25 @@ class LemmaController extends ApiBaseController
if (!$data) { if (!$data) {
return $this->createJsonResponse(401, ['error' => sprintf("Json non valide")]); return $this->createJsonResponse(401, ['error' => sprintf("Json non valide")]);
} }
if ($missingFields = $this->getMissingFields($data, ['lemma', 'language'])) { if ($missingFields = $this->getMissingFields($data, ['headword', 'language'])) {
return $this->createJsonResponse(401, ['error' => sprintf("Veuillez fournir une valeur pour: %s", implode(', ', $missingFields))]); return $this->createJsonResponse(401, ['error' => sprintf("Veuillez fournir une valeur pour: %s", implode(', ', $missingFields))]);
} }
$lemma = $this->doctrine->getRepository(Lemma::class)->findOneBy([ $headword = $this->doctrine->getRepository(Headword::class)->findOneBy([
'value' => $data['lemma'], 'value' => $data['headword'],
'language' => $data['language'], 'language' => $data['language'],
]); ]);
if (!$lemma) { if (!$headword) {
return $this->createJsonResponse(401, ['error' => sprintf("Pas de lemme trouvé pour cette valeur et cette langue")]); return $this->createJsonResponse(401, ['error' => sprintf("Pas de mot-vedette trouvé pour cette valeur et cette langue")]);
} }
if (! $lemma->getEntries()->isEmpty()) { if (! $headword->getEntries()->isEmpty()) {
return $this->createJsonResponse(403, ['error' => sprintf("Impossible de supprimer ce lemme car il est lié à des entrées")]); return $this->createJsonResponse(403, ['error' => sprintf("Impossible de supprimer ce mot-vedette car il est lié à des entrées")]);
} }
$this->doctrine->getManager()->remove($lemma); $this->doctrine->getManager()->remove($headword);
$this->doctrine->getManager()->flush(); $this->doctrine->getManager()->flush();
return $this->createJsonResponse(200, ['success' => sprintf("Lemme %s supprimé pour la langue %s", $data['lemma'], $data['language'])]); return $this->createJsonResponse(200, ['success' => sprintf("Mot-vedette %s supprimé pour la langue %s", $data['headword'], $data['language'])]);
} }
} }
...@@ -32,7 +32,7 @@ class IndexController extends AbstractController ...@@ -32,7 +32,7 @@ class IndexController extends AbstractController
return $this->render('index/index.html.twig', [ return $this->render('index/index.html.twig', [
'entry' => $serializer->serialize($entry, 'json', ['groups' => "entry:read"]), 'entry' => $serializer->serialize($entry, 'json', ['groups' => "entry:read"]),
'testJson' => json_encode([ 'testJson' => json_encode([
'lemma' => 1, 'headword' => 1,
'lexicons' => [4, 5], 'lexicons' => [4, 5],
'user' => $this->getUser()->getId() 'user' => $this->getUser()->getId()
]), ]),
......
...@@ -4,7 +4,7 @@ namespace App\Controller; ...@@ -4,7 +4,7 @@ namespace App\Controller;
use App\Entity\Entry; use App\Entity\Entry;
use App\Entity\Graphy; use App\Entity\Graphy;
use App\Entity\Lemma; use App\Entity\Headword;
use App\Entity\Lexicon; use App\Entity\Lexicon;
use App\Entity\User; use App\Entity\User;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
...@@ -50,7 +50,7 @@ class LexiconController extends ApiBaseController ...@@ -50,7 +50,7 @@ class LexiconController extends ApiBaseController
if ($entry === null) { if ($entry === null) {
return $this->createJsonResponse(401, ['error' => sprintf("Invalid Entry Id")]); return $this->createJsonResponse(401, ['error' => sprintf("Invalid Entry Id")]);
} }
$content = $serializer->serialize($entry, 'json', ['groups' => ["entry:read", "lemma:read", "lexicon:read"]]); $content = $serializer->serialize($entry, 'json', ['groups' => ["entry:read", "headword:read", "lexicon:read"]]);
return new JsonResponse($content, 200, [], true); return new JsonResponse($content, 200, [], true);
} }
......
...@@ -12,8 +12,8 @@ use Symfony\Component\Serializer\Annotation\Groups; ...@@ -12,8 +12,8 @@ use Symfony\Component\Serializer\Annotation\Groups;
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
* @ORM\Table( * @ORM\Table(
* uniqueConstraints={ * uniqueConstraints={
* @ORM\UniqueConstraint(name="lemma_lexicon", * @ORM\UniqueConstraint(name="headword_lexicon",
* columns={"lemma_id", "lexicon_id"}) * columns={"headword_id", "lexicon_id"})
* } * }
* ) * )
*/ */
...@@ -55,10 +55,10 @@ class Entry ...@@ -55,10 +55,10 @@ class Entry
/** /**
* @Groups({"entry:read", "entry:write"}) * @Groups({"entry:read", "entry:write"})
* @ORM\ManyToOne(targetEntity=Lemma::class, inversedBy="entries", fetch="EAGER") * @ORM\ManyToOne(targetEntity=Headword::class, inversedBy="entries", fetch="EAGER")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
private $lemma; private $headword;
/** /**
* @Groups({"entry:read"}) * @Groups({"entry:read"})
...@@ -78,7 +78,7 @@ class Entry ...@@ -78,7 +78,7 @@ class Entry
public function __toString() public function __toString()
{ {
return $this->getLemma()->getValue(); return $this->getHeadword()->getValue();
} }
/** /**
...@@ -158,14 +158,14 @@ class Entry ...@@ -158,14 +158,14 @@ class Entry
return $this; return $this;
} }
public function getLemma(): ?Lemma public function getHeadword(): ?Headword
{ {
return $this->lemma; return $this->headword;
} }
public function setLemma(?Lemma $lemma): self public function setHeadword(?Headword $headword): self
{ {
$this->lemma = $lemma; $this->headword = $headword;
return $this; return $this;
} }
......
...@@ -35,9 +35,9 @@ class Graphy ...@@ -35,9 +35,9 @@ class Graphy
private $language; private $language;
/** /**
* @ORM\ManyToMany(targetEntity=Lemma::class, inversedBy="graphies") * @ORM\ManyToMany(targetEntity=Headword::class, inversedBy="graphies")
*/ */
private $lemmas; private $headwords;
/** /**
* @ORM\Column(type="datetime_immutable") * @ORM\Column(type="datetime_immutable")
...@@ -51,7 +51,7 @@ class Graphy ...@@ -51,7 +51,7 @@ class Graphy
public function __construct() public function __construct()
{ {
$this->lemmas = new ArrayCollection(); $this->headwords = new ArrayCollection();
} }
public function __toString() public function __toString()
...@@ -101,25 +101,25 @@ class Graphy ...@@ -101,25 +101,25 @@ class Graphy
} }
/** /**
* @return Collection<int, Lemma> * @return Collection<int, Headword>
*/ */
public function getLemmas(): Collection public function getHeadwords(): Collection
{ {
return $this->lemmas; return $this->headwords;
} }
public function addLemma(Lemma $lemma): self public function addHeadword(Headword $headword): self
{ {
if (!$this->lemmas->contains($lemma)) { if (!$this->headwords->contains($headword)) {
$this->lemmas[] = $lemma; $this->headwords[] = $headword;
} }
return $this; return $this;
} }
public function removeLemma(Lemma $lemma): self public function removeHeadword(Headword $headword): self
{ {
$this->lemmas->removeElement($lemma); $this->headwords->removeElement($headword);
return $this; return $this;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
namespace App\Entity; namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource; use ApiPlatform\Core\Annotation\ApiResource;
use App\Repository\LemmaRepository; use App\Repository\HeadwordRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
...@@ -11,10 +11,10 @@ use Symfony\Component\Serializer\Annotation\Groups; ...@@ -11,10 +11,10 @@ use Symfony\Component\Serializer\Annotation\Groups;
/** /**
* @ORM\Entity(repositoryClass=LemmaRepository::class) * @ORM\Entity(repositoryClass=HeadwordRepository::class)
* @ORM\HasLifecycleCallbacks * @ORM\HasLifecycleCallbacks
*/ */
class Lemma class Headword
{ {
/** /**
* @ORM\Id * @ORM\Id
...@@ -25,24 +25,24 @@ class Lemma ...@@ -25,24 +25,24 @@ class Lemma
/** /**
* @ORM\Column(type="string", length=255) * @ORM\Column(type="string", length=255)
* @Groups({"lemma:read", "lemma:write"}) * @Groups({"headword:read", "headword:write"})
*/ */
private $value; private $value;
/** /**
* @ORM\Column(type="string", length=100) * @ORM\Column(type="string", length=100)
* @Groups({"lemma:read", "lemma:write"}) * @Groups({"headword:read", "headword:write"})
*/ */
private $language; private $language;
/** /**
* @ORM\OneToMany(targetEntity=Label::class, mappedBy="lemma") * @ORM\OneToMany(targetEntity=Label::class, mappedBy="headword")
*/ */
private $labels; private $labels;
/** /**
* @ORM\ManyToMany(targetEntity=Graphy::class, mappedBy="lemmas") * @ORM\ManyToMany(targetEntity=Graphy::class, mappedBy="headwords")
* @Groups({"lemma:write"}) * @Groups({"headword:write"})
*/ */
private $graphies; private $graphies;
...@@ -57,7 +57,7 @@ class Lemma ...@@ -57,7 +57,7 @@ class Lemma
private $updatedAt; private $updatedAt;
/** /**
* @ORM\OneToMany(targetEntity=Entry::class, mappedBy="lemma", orphanRemoval=true) * @ORM\OneToMany(targetEntity=Entry::class, mappedBy="headword", orphanRemoval=true)
*/ */
private $entries; private $entries;
...@@ -126,7 +126,7 @@ class Lemma ...@@ -126,7 +126,7 @@ class Lemma
{ {
if (!$this->labels->contains($label)) { if (!$this->labels->contains($label)) {
$this->labels[] = $label; $this->labels[] = $label;
$label->setLemma($this); $label->setHeadword($this);
} }
return $this; return $this;
...@@ -136,8 +136,8 @@ class Lemma ...@@ -136,8 +136,8 @@ class Lemma
{ {
if ($this->labels->removeElement($label)) { if ($this->labels->removeElement($label)) {
// set the owning side to null (unless already changed) // set the owning side to null (unless already changed)
if ($label->getLemma() === $this) { if ($label->getHeadword() === $this) {
$label->setLemma(null); $label->setHeadword(null);
} }
} }
...@@ -156,7 +156,7 @@ class Lemma ...@@ -156,7 +156,7 @@ class Lemma
{ {
if (!$this->graphies->contains($graphy)) { if (!$this->graphies->contains($graphy)) {
$this->graphies[] = $graphy; $this->graphies[] = $graphy;
$graphy->addLemma($this); $graphy->addHeadword($this);
} }
return $this; return $this;
...@@ -165,7 +165,7 @@ class Lemma ...@@ -165,7 +165,7 @@ class Lemma
public function removeGraphy(Graphy $graphy): self public function removeGraphy(Graphy $graphy): self
{ {
if ($this->graphies->removeElement($graphy)) { if ($this->graphies->removeElement($graphy)) {
$graphy->removeLemma($this); $graphy->removeHeadword($this);
} }
return $this; return $this;
...@@ -207,7 +207,7 @@ class Lemma ...@@ -207,7 +207,7 @@ class Lemma
{ {
if (!$this->entries->contains($entry)) { if (!$this->entries->contains($entry)) {
$this->entries[] = $entry; $this->entries[] = $entry;
$entry->setLemma($this); $entry->setHeadword($this);
} }
return $this; return $this;
...@@ -217,8 +217,8 @@ class Lemma ...@@ -217,8 +217,8 @@ class Lemma
{ {
if ($this->entries->removeElement($entry)) { if ($this->entries->removeElement($entry)) {
// set the owning side to null (unless already changed) // set the owning side to null (unless already changed)
if ($entry->getLemma() === $this) { if ($entry->getHeadword() === $this) {
$entry->setLemma(null); $entry->setHeadword(null);
} }
} }
......
...@@ -29,10 +29,10 @@ class Label ...@@ -29,10 +29,10 @@ class Label
private $milestone; private $milestone;
/** /**
* @ORM\ManyToOne(targetEntity=Lemma::class, inversedBy="labels") * @ORM\ManyToOne(targetEntity=Headword::class, inversedBy="labels")
* @ORM\JoinColumn(nullable=false) * @ORM\JoinColumn(nullable=false)
*/ */
private $lemma; private $headword;
/** /**
* @ORM\Column(type="datetime_immutable") * @ORM\Column(type="datetime_immutable")
...@@ -89,14 +89,14 @@ class Label ...@@ -89,14 +89,14 @@ class Label
return $this; return $this;
} }
public function getLemma(): ?Lemma public function getHeadword(): ?Headword
{ {
return $this->lemma; return $this->headword;
} }
public function setLemma(?Lemma $lemma): self public function setHeadword(?Headword $headword): self
{ {
$this->lemma = $lemma; $this->headword = $headword;
return $this; return $this;
} }
......
...@@ -24,7 +24,7 @@ class EntryRepository extends ServiceEntityRepository ...@@ -24,7 +24,7 @@ class EntryRepository extends ServiceEntityRepository
public function search($filter) public function search($filter)
{ {
$qb = $this->createQueryBuilder('e') $qb = $this->createQueryBuilder('e')
->leftJoin('e.lemma', 'lem') ->leftJoin('e.headword', 'lem')
->leftJoin('lem.graphies', 'g') ->leftJoin('lem.graphies', 'g')
->leftJoin('e.lexicon', 'lex') ->leftJoin('e.lexicon', 'lex')
; ;
...@@ -41,9 +41,9 @@ class EntryRepository extends ServiceEntityRepository ...@@ -41,9 +41,9 @@ class EntryRepository extends ServiceEntityRepository
; ;
} }
if ($filter['lemma'] ?? null) { if ($filter['headword'] ?? null) {
$qb->andWhere('lem.value = :lemma') $qb->andWhere('lem.value = :headword')
->setParameter('lemma', $filter['lemma']) ->setParameter('headword', $filter['headword'])
; ;
} }
......
...@@ -2,26 +2,26 @@ ...@@ -2,26 +2,26 @@
namespace App\Repository; namespace App\Repository;
use App\Entity\Lemma; use App\Entity\Headword;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\Persistence\ManagerRegistry;
/** /**
* @extends ServiceEntityRepository<Lemma> * @extends ServiceEntityRepository<Headword>
* *
* @method Lemma|null find($id, $lockMode = null, $lockVersion = null) * @method Headword|null find($id, $lockMode = null, $lockVersion = null)
* @method Lemma|null findOneBy(array $criteria, array $orderBy = null) * @method Headword|null findOneBy(array $criteria, array $orderBy = null)
* @method Lemma[] findAll() * @method Headword[] findAll()
* @method Lemma[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method Headword[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class LemmaRepository extends ServiceEntityRepository class HeadwordRepository extends ServiceEntityRepository
{ {
public function __construct(ManagerRegistry $registry) public function __construct(ManagerRegistry $registry)
{ {
parent::__construct($registry, Lemma::class); parent::__construct($registry, Headword::class);
} }
public function add(Lemma $entity, bool $flush = false): void public function add(Headword $entity, bool $flush = false): void
{ {
$this->getEntityManager()->persist($entity); $this->getEntityManager()->persist($entity);
...@@ -30,7 +30,7 @@ class LemmaRepository extends ServiceEntityRepository ...@@ -30,7 +30,7 @@ class LemmaRepository extends ServiceEntityRepository
} }
} }
public function remove(Lemma $entity, bool $flush = false): void public function remove(Headword $entity, bool $flush = false): void
{ {
$this->getEntityManager()->remove($entity); $this->getEntityManager()->remove($entity);
...@@ -40,7 +40,7 @@ class LemmaRepository extends ServiceEntityRepository ...@@ -40,7 +40,7 @@ class LemmaRepository extends ServiceEntityRepository
} }
/** /**
* @return Lemma[] * @return Headword[]
*/ */
public function getByGraphyValue($value): array public function getByGraphyValue($value): array
{ {
...@@ -53,7 +53,7 @@ class LemmaRepository extends ServiceEntityRepository ...@@ -53,7 +53,7 @@ class LemmaRepository extends ServiceEntityRepository
; ;
} }
// public function findOneBySomeField($value): ?Lemma // public function findOneBySomeField($value): ?Headword
// { // {
// return $this->createQueryBuilder('l') // return $this->createQueryBuilder('l')
// ->andWhere('l.exampleField = :val') // ->andWhere('l.exampleField = :val')
......
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