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

@@ -22,13 +22,16 @@ namespace Chill\PersonBundle\Export\Aggregator;
use Chill\MainBundle\Export\AggregatorInterface;
use Doctrine\ORM\QueryBuilder;
use Symfony\Component\Form\Extension\Core\Type\DateType;
use Chill\MainBundle\Export\ExportElementValidatedInterface;
use Symfony\Component\Validator\Context\ExecutionContextInterface;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class AgeAggregator implements AggregatorInterface
class AgeAggregator implements AggregatorInterface,
ExportElementValidatedInterface
{
public function addRole()
@@ -58,6 +61,14 @@ class AgeAggregator implements AggregatorInterface
'format' => 'dd-MM-yyyy'
));
}
public function validateForm($data, ExecutionContextInterface $context)
{
if ($data['date_age_calculation'] === null) {
$context->buildViolation("The date should not be empty")
->addViolation();
}
}
public function getLabels($key, array $values, $data)
{