fix deprecations: replace many strings by fqcn

This commit is contained in:
nobohan
2018-04-04 15:02:16 +02:00
parent 2eb81ab3ec
commit 678386ffd6
7 changed files with 168 additions and 159 deletions

View File

@@ -24,29 +24,31 @@ namespace Chill\PersonBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Chill\PersonBundle\Form\Type\GenderType;
use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Chill\PersonBundle\Form\Type\GenderType;
use Chill\MainBundle\Form\Type\DataTransformer\CenterTransformer;
class CreationPersonType extends AbstractType
{
const NAME = 'chill_personbundle_person_creation';
const FORM_NOT_REVIEWED = 'not_reviewed';
const FORM_REVIEWED = 'reviewed' ;
const FORM_BEING_REVIEWED = 'being_reviewed';
/**
*
* @var CenterTransformer
*/
private $centerTransformer;
public function __construct(CenterTransformer $centerTransformer) {
$this->centerTransformer = $centerTransformer;
}
/**
* @param FormBuilderInterface $builder
* @param array $options
@@ -54,24 +56,24 @@ class CreationPersonType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['form_status'] === self::FORM_BEING_REVIEWED) {
$dateToStringTransformer = new DateTimeToStringTransformer(
null, null, 'd-m-Y', false);
$builder->add('firstName', 'hidden')
->add('lastName', 'hidden')
->add('birthdate', 'hidden', array(
$builder->add('firstName', HiddenType::class)
->add('lastName', HiddenType::class)
->add('birthdate', HiddenType::class, array(
'property_path' => 'birthdate'
))
->add('gender', 'hidden')
->add('creation_date', 'hidden', array(
->add('gender', HiddenType::class)
->add('creation_date', HiddenType::class, array(
'mapped' => false
))
->add('form_status', 'hidden', array(
->add('form_status', HiddenType::class, array(
'mapped' => false,
'data' => $options['form_status']
))
->add('center', 'hidden')
->add('center', HiddenType::class)
;
$builder->get('birthdate')
->addModelTransformer($dateToStringTransformer);
@@ -83,18 +85,18 @@ class CreationPersonType extends AbstractType
$builder
->add('firstName')
->add('lastName')
->add('birthdate', 'date', array('required' => false,
->add('birthdate', 'date', array('required' => false,
'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
->add('gender', new GenderType(), array(
'required' => true, 'empty_value' => null
))
->add('creation_date', 'date', array(
'required' => true,
'widget' => 'single_text',
'required' => true,
'widget' => 'single_text',
'format' => 'dd-MM-yyyy',
'mapped' => false,
'data' => new \DateTime()))
->add('form_status', 'hidden', array(
->add('form_status', HiddenType::class, array(
'data' => $options['form_status'],
'mapped' => false
))
@@ -102,7 +104,7 @@ class CreationPersonType extends AbstractType
;
}
}
/**
* @param OptionsResolver $resolver
*/
@@ -111,7 +113,7 @@ class CreationPersonType extends AbstractType
$resolver->setDefaults(array(
'data_class' => 'Chill\PersonBundle\Entity\Person'
));
$resolver->setRequired('form_status')
->setAllowedValues('form_status', array(
self::FORM_BEING_REVIEWED,