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