Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit e7623f0d authored by Arnaud Bey's avatar Arnaud Bey
Browse files

fix findword objective stuff

parent 77d17d2c
......@@ -18,4 +18,23 @@ class RootRepository extends \Doctrine\ORM\EntityRepository
->getResult()
;
}
public function getByContentAndLanguage($findWord)
{
$em = $this->_em;
$dql = 'SELECT r FROM LexiconBundle\Entity\Root r
WHERE EXISTS(
SELECT w FROM LexiconBundle\Entity\Word w
WHERE w.root = r
AND w.cleanValue = :cleanValue
AND w.language = :language
)';
$query = $em->createQuery($dql);
$query->setParameter('cleanValue', $findWord->getInflection());
$query->setParameter('language', $findWord->getConquer()->getLanguage());
return $query->getResult();
}
}
......@@ -138,4 +138,57 @@ class FindWord extends Objective
return $jsonArray;
}
/**
* Add root.
*
* @param \LexiconBundle\Entity\Root $root
*
* @return FindWord
*/
public function addRoot(\LexiconBundle\Entity\Root $root)
{
$this->roots[] = $root;
return $this;
}
/**
* Add lemmas.
*
* @param \MagicWordBundle\Entity\Lexicon\Lemma $lemma
*
* @return FindWord
*/
public function addRoots($roots)
{
foreach ($roots as $root) {
$this->roots[] = $root;
}
return $this;
}
/**
* Remove root.
*
* @param \LexiconBundle\Entity\Root $root
*
* @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
*/
public function removeRoot(\LexiconBundle\Entity\Root $root)
{
return $this->roots->removeElement($root);
}
/**
* Get roots.
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getRoots()
{
return $this->roots;
}
}
......@@ -34,12 +34,12 @@ class FindWordType extends AbstractType
));
$builder->add('lemmaEnough', ChoiceType::class, array(
'label' => 'Is root enough ?',
'label' => false,
'required' => true,
'choices' => array(
'Non' => '0',
'Oui' => '1',
),
'choices' => [
'Root pas suffisant ' => '0',
'Root suffisant' => '1',
],
));
}
......
......@@ -95,10 +95,12 @@ class ObjectiveManager
private function handleFindWord($objective)
{
$repo = $this->em->getRepository('LexiconBundle:Root');
$objective->getRoots()->clear();
if ($objective->getRoots()) {
$objective->getRoots()->clear();
}
if ($objective->getLemmaEnough()) {
$repo = $this->em->getRepository('LexiconBundle:Root');
$roots = $repo->getByContentAndLanguage($objective);
$objective->addRoots($roots);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment