Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mathieu Loiseau
MagicWord
Commits
e7623f0d
Commit
e7623f0d
authored
May 20, 2019
by
Arnaud Bey
Browse files
fix findword objective stuff
parent
77d17d2c
Changes
4
Hide whitespace changes
Inline
Side-by-side
application/src/LexiconBundle/Repository/RootRepository.php
View file @
e7623f0d
...
...
@@ -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
();
}
}
application/src/MagicWordBundle/Entity/ObjectiveType/FindWord.php
View file @
e7623f0d
...
...
@@ -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
;
}
}
application/src/MagicWordBundle/Form/Type/ObjectiveType/FindWordType.php
View file @
e7623f0d
...
...
@@ -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'
,
]
,
));
}
...
...
application/src/MagicWordBundle/Manager/ObjectiveManager.php
View file @
e7623f0d
...
...
@@ -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
);
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment