add validation on aggregators and filters

This commit is contained in:
2017-02-02 22:58:47 +01:00
parent cc91ade6fe
commit 1512832774
7 changed files with 104 additions and 40 deletions

View File

@@ -28,13 +28,16 @@ use Symfony\Component\Translation\TranslatorInterface;
use Chill\MainBundle\Util\CountriesInfo;
use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class NationalityAggregator implements AggregatorInterface
class NationalityAggregator implements AggregatorInterface,
ExportElementValidatedInterface
{
/**
*
@@ -82,6 +85,14 @@ class NationalityAggregator implements AggregatorInterface
));
}
public function validateForm($data, ExecutionContextInterface $context)
{
if ($data['group_by_level'] === null) {
$context->buildViolation("You should select an option")
->addViolation();
}
}
public function alterQuery(QueryBuilder $qb, $data)
{