fix deprecations: use fqcn instead of 'choices'

This commit is contained in:
nobohan
2018-04-04 15:55:45 +02:00
parent 65e7354437
commit b84ee91652
7 changed files with 100 additions and 92 deletions

View File

@@ -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>, <info@champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
@@ -28,6 +28,7 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Bundle\TwigBundle\TwigEngine;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
* @author Julien Fastré <julien.fastre@champs-libres.coop>
@@ -35,21 +36,21 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
*/
class CustomFieldText extends AbstractCustomField
{
private $requestStack;
/**
*
*
* @var TwigEngine
*/
private $templating;
/**
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
*/
private $translatableStringHelper;
public function __construct(RequestStack $requestStack, TwigEngine $templating,
TranslatableStringHelper $translatableStringHelper)
{
@@ -57,16 +58,16 @@ class CustomFieldText extends AbstractCustomField
$this->templating = $templating;
$this->translatableStringHelper = $translatableStringHelper;
}
const MAX_LENGTH = 'maxLength';
const MULTIPLE_CF_INLINE ='multipleCFInline';
/**
* Create a form according to the maxLength option
*
*
* if maxLength < 256 THEN the form type is 'text'
* if not, THEN the form type is textarea
*
*
* @param FormBuilderInterface $builder
* @param CustomField $customField
*/
@@ -74,16 +75,16 @@ class CustomFieldText extends AbstractCustomField
{
$options = $customField->getOptions();
$type = ($options[self::MAX_LENGTH] < 256) ? 'text'
$type = ($options[self::MAX_LENGTH] < 256) ? 'text'
: 'textarea';
$attrArray = array();
if(array_key_exists(self::MULTIPLE_CF_INLINE, $options) and
$options[self::MULTIPLE_CF_INLINE]) {
$attrArray['class'] = 'multiple-cf-inline';
$attrArray['class'] = 'multiple-cf-inline';
}
$builder->add($customField->getSlug(), $type, array(
'label' => $this->translatableStringHelper->localize($customField->getName()),
'required' => false,
@@ -121,9 +122,9 @@ class CustomFieldText extends AbstractCustomField
{
return $builder
->add(self::MAX_LENGTH, 'integer', array('empty_data' => 256))
->add(self::MULTIPLE_CF_INLINE, 'choice', array(
->add(self::MULTIPLE_CF_INLINE, ChoiceType::class, array(
'choices' => array(
'1' => 'Multiple boxes on the line',
'1' => 'Multiple boxes on the line',
'0' => 'One box on the line'
),
'label' => 'Box appearance',