mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix deprecations: use fqcn for formtype
This commit is contained in:
parent
7e36eee27a
commit
7119de8223
@ -22,11 +22,13 @@ namespace Chill\MainBundle\Form\Type\Export;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\MainBundle\Export\ExportManager;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||
|
||||
use Chill\MainBundle\Export\ExportManager;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
@ -37,34 +39,34 @@ class AggregatorType extends AbstractType
|
||||
* @var \ExportManager
|
||||
*/
|
||||
private $exportManager;
|
||||
|
||||
|
||||
public function __construct(ExportManager $exportManager)
|
||||
{
|
||||
$this->exportManager = $exportManager;
|
||||
}
|
||||
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$aggregator = $this->exportManager->getAggregator($options['aggregator_alias']);
|
||||
|
||||
|
||||
$builder
|
||||
->add('enabled', CheckboxType::class, array(
|
||||
'value' => true,
|
||||
'required' => false,
|
||||
'data' => false
|
||||
));
|
||||
|
||||
$filterFormBuilder = $builder->create('form', 'form', array(
|
||||
'compound' => true,
|
||||
|
||||
$filterFormBuilder = $builder->create('form', FormType::class, array(
|
||||
'compound' => true,
|
||||
'required' => false,
|
||||
'error_bubbling' => false
|
||||
));
|
||||
$aggregator->buildForm($filterFormBuilder);
|
||||
|
||||
|
||||
$builder->add($filterFormBuilder);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setRequired('aggregator_alias')
|
||||
@ -72,5 +74,5 @@ class AggregatorType extends AbstractType
|
||||
->setDefault('error_bubbling', false)
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS,
|
||||
* <http://www.champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
@ -35,7 +35,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
@ -46,39 +46,39 @@ class ExportType extends AbstractType
|
||||
* @var ExportManager
|
||||
*/
|
||||
protected $exportManager;
|
||||
|
||||
|
||||
const FILTER_KEY = 'filters';
|
||||
const AGGREGATOR_KEY = 'aggregators';
|
||||
const PICK_FORMATTER_KEY = 'pick_formatter';
|
||||
const EXPORT_KEY = 'export';
|
||||
|
||||
|
||||
public function __construct(ExportManager $exportManager)
|
||||
{
|
||||
$this->exportManager = $exportManager;
|
||||
}
|
||||
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$export = $this->exportManager->getExport($options['export_alias']);
|
||||
|
||||
|
||||
$exportOptions = array(
|
||||
'compound' => true,
|
||||
'constraints' => array(
|
||||
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
// add a contraint if required by export
|
||||
$exportBuilder = $builder->create(self::EXPORT_KEY/*, FormType::class, $exportOptions*/);
|
||||
|
||||
|
||||
$export->buildForm($exportBuilder);
|
||||
|
||||
$builder->add($exportBuilder, null, $exportOptions);
|
||||
|
||||
|
||||
//add filters
|
||||
$filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']);
|
||||
$filterBuilder = $builder->create(self::FILTER_KEY, 'form', array('compound' => true));
|
||||
|
||||
$filterBuilder = $builder->create(self::FILTER_KEY, FormType::class, array('compound' => true));
|
||||
|
||||
foreach($filters as $alias => $filter) {
|
||||
$filterBuilder->add($alias, new FilterType($this->exportManager), array(
|
||||
'filter_alias' => $alias,
|
||||
@ -88,15 +88,15 @@ class ExportType extends AbstractType
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$builder->add($filterBuilder);
|
||||
|
||||
//add aggregators
|
||||
|
||||
//add aggregators
|
||||
$aggregators = $this->exportManager
|
||||
->getAggregatorsApplyingOn($export, $options['picked_centers']);
|
||||
$aggregatorBuilder = $builder->create(self::AGGREGATOR_KEY, 'form',
|
||||
$aggregatorBuilder = $builder->create(self::AGGREGATOR_KEY, FormType::class,
|
||||
array('compound' => true));
|
||||
|
||||
|
||||
foreach($aggregators as $alias => $aggregator) {
|
||||
$aggregatorBuilder->add($alias, new AggregatorType($this->exportManager), array(
|
||||
'aggregator_alias' => $alias,
|
||||
@ -106,22 +106,22 @@ class ExportType extends AbstractType
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
$builder->add($aggregatorBuilder);
|
||||
|
||||
|
||||
// add export form
|
||||
$exportBuilder = $builder->create(self::EXPORT_KEY, FormType::class, array('compound' => true));
|
||||
$this->exportManager->getExport($options['export_alias'])
|
||||
->buildForm($exportBuilder);
|
||||
$builder->add($exportBuilder);
|
||||
|
||||
|
||||
$builder->add(self::PICK_FORMATTER_KEY, PickFormatterType::class, array(
|
||||
'export_alias' => $options['export_alias']
|
||||
));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setRequired(array('export_alias', 'picked_centers'))
|
||||
@ -131,9 +131,9 @@ class ExportType extends AbstractType
|
||||
//new \Chill\MainBundle\Validator\Constraints\Export\ExportElementConstraint()
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return FormType::class;
|
||||
|
Loading…
x
Reference in New Issue
Block a user