diff --git a/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php b/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php index e5d0887f3..fe4c43830 100644 --- a/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php +++ b/src/Bundle/ChillMainBundle/Form/Type/Export/ExportType.php @@ -18,6 +18,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\FormType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; class ExportType extends AbstractType { @@ -29,7 +30,15 @@ class ExportType extends AbstractType final public const PICK_FORMATTER_KEY = 'pick_formatter'; - public function __construct(private readonly ExportManager $exportManager, private readonly SortExportElement $sortExportElement) {} + private array $personFieldsConfig; + + public function __construct( + private readonly ExportManager $exportManager, + private readonly SortExportElement $sortExportElement, + protected ParameterBagInterface $parameterBag, + ) { + $this->personFieldsConfig = $parameterBag->get('chill_person.person_fields'); + } public function buildForm(FormBuilderInterface $builder, array $options) { @@ -77,6 +86,17 @@ class ExportType extends AbstractType ); foreach ($aggregators as $alias => $aggregator) { + /* + * eventually mask aggregator + */ + if (str_starts_with((string) $alias, 'person_') and str_ends_with((string) $alias, '_aggregator')) { + $field = preg_replace(['/person_/', '/_aggregator/'], '', (string) $alias); + if (array_key_exists($field, $this->personFieldsConfig) and 'visible' !== $this->personFieldsConfig[$field]) { + continue; + } + } + + $aggregatorBuilder->add($alias, AggregatorType::class, [ 'aggregator_alias' => $alias, 'export_manager' => $this->exportManager,