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

fix import/export

parent 82f12d05
...@@ -63,9 +63,13 @@ class Constraint extends Objective ...@@ -63,9 +63,13 @@ class Constraint extends Objective
$jsonArray = array( $jsonArray = array(
'type' => $this->discr, 'type' => $this->discr,
'numberToFind' => $this->numberToFind, 'numberToFind' => $this->numberToFind,
'features' => $this->feature ? $this->feature->getId() : null, 'features' => []
); );
foreach ($this->features as $feature) {
$jsonArray["features"][] = $feature->getId();
}
return $jsonArray; return $jsonArray;
} }
/** /**
......
...@@ -108,29 +108,12 @@ class ImportManager ...@@ -108,29 +108,12 @@ class ImportManager
$properties = []; $properties = [];
$properties['numberToFind'] = $objectiveJSON['numberToFind']; $properties['numberToFind'] = $objectiveJSON['numberToFind'];
$properties['category'] = ($objectiveJSON['category']) $properties['features'] = [];
? $this->em->getRepository('LexiconBundle:Category')->findOneById($objectiveJSON['category']) foreach ($objectiveJSON['features'] as $f) {
: null; if ($feature = $this->em->getRepository('LexiconBundle:Feature')->findOneById($f)) {
$properties['features'][] = $feature;
$properties['gender'] = ($objectiveJSON['gender']) }
? $this->em->getRepository('LexiconBundle:Gender')->findOneById($objectiveJSON['gender']) }
: null;
$properties['tense'] = ($objectiveJSON['tense'])
? $this->em->getRepository('LexiconBundle:Tense')->findOneById($objectiveJSON['tense'])
: null;
$properties['person'] = ($objectiveJSON['person'])
? $this->em->getRepository('LexiconBundle:Person')->findOneById($objectiveJSON['person'])
: null;
$properties['mood'] = ($objectiveJSON['mood'])
? $this->em->getRepository('LexiconBundle:Mood')->findOneById($objectiveJSON['mood'])
: null;
$properties['number'] = ($objectiveJSON['number'])
? $this->em->getRepository('LexiconBundle:Number')->findOneById($objectiveJSON['number'])
: null;
$this->objectiveManager->generateConstraint($round, $properties); $this->objectiveManager->generateConstraint($round, $properties);
......
...@@ -173,13 +173,10 @@ class ObjectiveManager ...@@ -173,13 +173,10 @@ class ObjectiveManager
{ {
$constraint = new Constraint(); $constraint = new Constraint();
foreach ($properties["features"] as $feature) {
$constraint->addFeature($feature);
}
$constraint->setNumberToFind($properties['numberToFind']); $constraint->setNumberToFind($properties['numberToFind']);
$constraint->setCategory($properties['category']);
$constraint->setGender($properties['gender']);
$constraint->setTense($properties['tense']);
$constraint->setPerson($properties['person']);
$constraint->setMood($properties['mood']);
$constraint->setNumber($properties['number']);
$constraint->setConquer($conquer); $constraint->setConquer($conquer);
$this->em->persist($constraint); $this->em->persist($constraint);
......
...@@ -31,9 +31,6 @@ ...@@ -31,9 +31,6 @@
{{ form_label(findWord.lemmaEnough) }} {{ form_label(findWord.lemmaEnough) }}
{{ form_widget(findWord.lemmaEnough) }} {{ form_widget(findWord.lemmaEnough) }}
<span class="float-right"> <span class="float-right">
<span class="btn btn-sm btn-outline-secondary disabled">
<i class="fa fa-wikipedia-w" aria-hidden="true"></i>
</span>
<span onclick="objectives.remove(this);" class="btn btn-sm btn-danger"> <span onclick="objectives.remove(this);" class="btn btn-sm btn-danger">
<i class="fa fa-times" aria-hidden="true"></i> <i class="fa fa-times" aria-hidden="true"></i>
</span> </span>
......
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