<?php

use Chill\MainBundle\Export\FilterInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

class MyFilter implements FilterInterface
{
    public function getTitle()
    {
        return "some title";
    }

    public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
    {
        $builder->add('field', ChoiceType::class, [
            'choices' => ['one', 'two', 'three', 'four', 'five'],
            'multiple' => false,
        ]);

        $builder->add('entity', EntityType::class, []);

        $builder->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, []);

        $builder->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class);

        $builder->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []);
    }

    public function getFormDefaultData(): array
    {
        return [];
    }

    public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
    {
        return [];
    }

    public function addRole(): ?string
    {
        return null;
    }

    public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
    {
        // nothing to add here
    }

    public function applyOn()
    {
        return ['something'];
    }
}

?>
-----
<?php

use Chill\MainBundle\Export\FilterInterface;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;

class MyFilter implements FilterInterface
{
    use \Chill\MainBundle\Export\ExportDataNormalizerTrait;
    public function getTitle()
    {
        return "some title";
    }

    public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
    {
        $builder->add('field', ChoiceType::class, [
            'choices' => ['one', 'two', 'three', 'four', 'five'],
            'multiple' => false,
        ]);

        $builder->add('entity', EntityType::class, []);

        $builder->add('user', \Chill\MainBundle\Form\Type\PickUserDynamicType::class, []);

        $builder->add('rolling_date', \Chill\MainBundle\Form\Type\PickRollingDateType::class);

        $builder->add('date', \Chill\MainBundle\Form\Type\ChillDateType::class, []);
    }
    public function getNormalizationVersion(): int
    {
        return 1;
    }
    public function normalizeFormData(array $formData): array
    {
        return ['field' => $formData['field'], 'entity' => $this->normalizeDoctrineEntity($formData['entity']), 'user' => $this->normalizeDoctrineEntity($formData['user']), 'rolling_date' => $formData['rolling_date']->normalize(), 'date' => $this->normalizeDate($formData['date'])];
    }
    public function denormalizeFormData(array $formData, int $fromVersion): array
    {
        return ['field' => $formData['field'], 'entity' => $this->denormalizeDoctrineEntity($formData['entity'], $this->someRepository), 'user' => $this->denormalizeDoctrineEntity($formData['user'], $this->someRepository), 'rolling_date' => \Chill\MainBundle\Service\RollingDate\RollingDate::fromNormalized($formData['rolling_date']), 'date' => $this->denormalizeDate($formData['date'])];
    }

    public function getFormDefaultData(): array
    {
        return [];
    }

    public function describeAction($data, \Chill\MainBundle\Export\ExportGenerationContext $context)
    {
        return [];
    }

    public function addRole(): ?string
    {
        return null;
    }

    public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data, \Chill\MainBundle\Export\ExportGenerationContext $exportGenerationContext)
    {
        // nothing to add here
    }

    public function applyOn()
    {
        return ['something'];
    }
}

?>
