mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-09 09:19:51 +00:00
ChillMainBundle: optionnaly mask aggegators in ExportType
This commit is contained in:
parent
98cf167040
commit
5f31473c90
@ -18,6 +18,7 @@ use Symfony\Component\Form\AbstractType;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||||
|
|
||||||
class ExportType extends AbstractType
|
class ExportType extends AbstractType
|
||||||
{
|
{
|
||||||
@ -29,7 +30,15 @@ class ExportType extends AbstractType
|
|||||||
|
|
||||||
final public const PICK_FORMATTER_KEY = 'pick_formatter';
|
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)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
@ -77,6 +86,17 @@ class ExportType extends AbstractType
|
|||||||
);
|
);
|
||||||
|
|
||||||
foreach ($aggregators as $alias => $aggregator) {
|
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, [
|
$aggregatorBuilder->add($alias, AggregatorType::class, [
|
||||||
'aggregator_alias' => $alias,
|
'aggregator_alias' => $alias,
|
||||||
'export_manager' => $this->exportManager,
|
'export_manager' => $this->exportManager,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user