add validation to activityreasonaggregator

This commit is contained in:
Julien Fastré 2017-02-26 00:12:52 +01:00
parent 9bcd7a2c10
commit 7a76868f6a
2 changed files with 14 additions and 2 deletions

View File

@ -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é <julien.fastre@champs-libres.coop>
*/
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";
}

View File

@ -0,0 +1 @@
The reasons's level should not be empty: Le niveau du sujet ne peut pas être vide