diff --git a/Export/Aggregator/ActivityReasonAggregator.php b/Export/Aggregator/ActivityReasonAggregator.php index b33c321ee..33eb0499e 100644 --- a/Export/Aggregator/ActivityReasonAggregator.php +++ b/Export/Aggregator/ActivityReasonAggregator.php @@ -27,13 +27,16 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter; use Doctrine\ORM\EntityRepository; use Chill\MainBundle\Templating\TranslatableStringHelper; use Doctrine\ORM\Query\Expr\Join; +use Chill\MainBundle\Export\ExportElementValidatedInterface; +use Symfony\Component\Validator\Context\ExecutionContextInterface; /** * * * @author Julien FastrĂ© */ -class ActivityReasonAggregator implements AggregatorInterface +class ActivityReasonAggregator implements AggregatorInterface, + ExportElementValidatedInterface { /** * @@ -150,8 +153,16 @@ class ActivityReasonAggregator implements AggregatorInterface 'label' => 'Reason\'s level' )); } + + public function validateForm($data, ExecutionContextInterface $context) + { + if ($data['level'] === null) { + $context->buildViolation("The reasons's level should not be empty") + ->addViolation(); + } + } - public function getTitle() + public function getTitle() { return "Aggregate by activity reason"; } diff --git a/Resources/translations/validators.fr.yml b/Resources/translations/validators.fr.yml new file mode 100644 index 000000000..831969641 --- /dev/null +++ b/Resources/translations/validators.fr.yml @@ -0,0 +1 @@ +The reasons's level should not be empty: Le niveau du sujet ne peut pas ĂȘtre vide