Commit 974698fe authored by Arnaud Bey's avatar Arnaud Bey
Browse files

WIP feature test

parent b10ed9e0
......@@ -202,16 +202,22 @@ class ObjectiveManager
}
break;
case 'constraint':
$foundables = $foundableRepo->getByGridAndCriteria($grid, $objective);
echo count($foundables);
die();
if (count($foundables) < $objective->getNumberToFind()) {
$errors[] = 'problème constraint non réalisable round '.$roundName;
$foundables = $grid->getFoundableForms();
foreach ($objective->getFeatures() as $feature) {
//$foundables = $foundableRepo->getByGridAndCriteria($grid, $objective);
$foundables = $foundableRepo->getByGridAndFeature($grid, $feature, $foundables);
if (count($foundables) < $objective->getNumberToFind()) {
$errors[] = 'problème constraint non réalisable round '.$roundName;
break;
}
}
// no break
default:
break;
}
}
var_dump($errors);
die();
return $errors;
}
......
......@@ -12,33 +12,17 @@ use LexiconBundle\Entity\Language;
*/
class FoundableRepository extends \Doctrine\ORM\EntityRepository
{
public function getByGridAndCriteria($grid, $objective)
public function feature()
{
}
public function getByGridAndFeature($grid, $feature, $foundables)
{
$em = $this->_em;
$dql = 'SELECT f FROM MagicWordBundle\Entity\FoundableForm f JOIN f.words w WHERE f.grid = :grid';
$dql .= ' AND :features MEMBER OF w.features';
/*
$i = 0;
foreach ($objective->getFeatures() as $f) {
$dql .= ' AND :feature-'.$i.' MEMBER OF w.features';
$i++;
}*/
$features = [];
foreach ($objective->getFeatures() as $f) {
$features[]=$f->getId();
}
$dql = 'SELECT f FROM MagicWordBundle\Entity\FoundableForm f JOIN f.words w WHERE f IN (:foundables) AND :feature MEMBER OF w.features';
$query = $em->createQuery($dql);
/*
$i = 0;
foreach ($objective->getFeatures() as $f) {
$query->setParameter('feature-'.$i, $f);
$i++;
}
*/
$query->setParameter('grid', $grid);
$query->setParameter('features', $features);
$query->setParameter('feature', $feature);
$query->setParameter('foundables', $foundables);
return $query->getResult();
}
......
Supports Markdown
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