mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
fix deprecations: use fqcn and pass arguments of class as options
This commit is contained in:
parent
7119de8223
commit
0287da70d7
@ -34,20 +34,15 @@ use Chill\MainBundle\Export\ExportManager;
|
|||||||
*/
|
*/
|
||||||
class AggregatorType extends AbstractType
|
class AggregatorType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var \ExportManager
|
|
||||||
*/
|
|
||||||
private $exportManager;
|
|
||||||
|
|
||||||
public function __construct(ExportManager $exportManager)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->exportManager = $exportManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$aggregator = $this->exportManager->getAggregator($options['aggregator_alias']);
|
$exportManager = $options['export_manager'];
|
||||||
|
$aggregator = $exportManager->getAggregator($options['aggregator_alias']);
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add('enabled', CheckboxType::class, array(
|
->add('enabled', CheckboxType::class, array(
|
||||||
@ -70,6 +65,7 @@ class AggregatorType extends AbstractType
|
|||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setRequired('aggregator_alias')
|
$resolver->setRequired('aggregator_alias')
|
||||||
|
->setRequired('export_manager')
|
||||||
->setDefault('compound', true)
|
->setDefault('compound', true)
|
||||||
->setDefault('error_bubbling', false)
|
->setDefault('error_bubbling', false)
|
||||||
;
|
;
|
||||||
|
@ -79,9 +79,12 @@ class ExportType extends AbstractType
|
|||||||
$filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']);
|
$filters = $this->exportManager->getFiltersApplyingOn($export, $options['picked_centers']);
|
||||||
$filterBuilder = $builder->create(self::FILTER_KEY, FormType::class, array('compound' => true));
|
$filterBuilder = $builder->create(self::FILTER_KEY, FormType::class, array('compound' => true));
|
||||||
|
|
||||||
|
dump($this->exportManager);
|
||||||
|
|
||||||
foreach($filters as $alias => $filter) {
|
foreach($filters as $alias => $filter) {
|
||||||
$filterBuilder->add($alias, new FilterType($this->exportManager), array(
|
$filterBuilder->add($alias, FilterType::class, array(
|
||||||
'filter_alias' => $alias,
|
'filter_alias' => $alias,
|
||||||
|
'export_manager' => $this->exportManager,
|
||||||
'label' => $filter->getTitle(),
|
'label' => $filter->getTitle(),
|
||||||
'constraints' => array(
|
'constraints' => array(
|
||||||
new ExportElementConstraint(['element' => $filter])
|
new ExportElementConstraint(['element' => $filter])
|
||||||
@ -94,12 +97,13 @@ class ExportType extends AbstractType
|
|||||||
//add aggregators
|
//add aggregators
|
||||||
$aggregators = $this->exportManager
|
$aggregators = $this->exportManager
|
||||||
->getAggregatorsApplyingOn($export, $options['picked_centers']);
|
->getAggregatorsApplyingOn($export, $options['picked_centers']);
|
||||||
$aggregatorBuilder = $builder->create(self::AGGREGATOR_KEY, FormType::class,
|
$aggregatorBuilder = $builder->create(self::AGGREGATOR_KEY, FormType::class,
|
||||||
array('compound' => true));
|
array('compound' => true));
|
||||||
|
|
||||||
foreach($aggregators as $alias => $aggregator) {
|
foreach($aggregators as $alias => $aggregator) {
|
||||||
$aggregatorBuilder->add($alias, new AggregatorType($this->exportManager), array(
|
$aggregatorBuilder->add($alias, AggregatorType::class, array(
|
||||||
'aggregator_alias' => $alias,
|
'aggregator_alias' => $alias,
|
||||||
|
'export_manager' => $this->exportManager,
|
||||||
'label' => $aggregator->getTitle(),
|
'label' => $aggregator->getTitle(),
|
||||||
'constraints' => array(
|
'constraints' => array(
|
||||||
new ExportElementConstraint(['element' => $aggregator])
|
new ExportElementConstraint(['element' => $aggregator])
|
||||||
|
@ -30,53 +30,49 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
use Symfony\Component\Form\Extension\Core\Type\FormType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class FilterType extends AbstractType
|
class FilterType extends AbstractType
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var \ExportManager
|
|
||||||
*/
|
|
||||||
private $exportManager;
|
|
||||||
|
|
||||||
const ENABLED_FIELD = 'enabled';
|
const ENABLED_FIELD = 'enabled';
|
||||||
|
|
||||||
public function __construct(ExportManager $exportManager)
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->exportManager = $exportManager;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
$filter = $this->exportManager->getFilter($options['filter_alias']);
|
|
||||||
|
$exportManager = $options['export_manager'];
|
||||||
|
$filter = $exportManager->getFilter($options['filter_alias']);
|
||||||
|
|
||||||
$builder
|
$builder
|
||||||
->add(self::ENABLED_FIELD, CheckboxType::class, array(
|
->add(self::ENABLED_FIELD, CheckboxType::class, array(
|
||||||
'value' => true,
|
'value' => true,
|
||||||
'data' => false,
|
'data' => false,
|
||||||
'required' => false
|
'required' => false
|
||||||
));
|
));
|
||||||
|
|
||||||
$filterFormBuilder = $builder->create('form', FormType::class, array(
|
$filterFormBuilder = $builder->create('form', FormType::class, array(
|
||||||
'compound' => true,
|
'compound' => true,
|
||||||
'error_bubbling' => false,
|
'error_bubbling' => false,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
));
|
));
|
||||||
$filter->buildForm($filterFormBuilder);
|
$filter->buildForm($filterFormBuilder);
|
||||||
|
|
||||||
$builder->add($filterFormBuilder);
|
$builder->add($filterFormBuilder);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
{
|
{
|
||||||
$resolver->setRequired('filter_alias')
|
$resolver->setRequired('filter_alias')
|
||||||
|
->setRequired('export_manager')
|
||||||
->setDefault('compound', true)
|
->setDefault('compound', true)
|
||||||
->setDefault('error_bubbling', false)
|
->setDefault('error_bubbling', false)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user