mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-14 14:24:24 +00:00
Refactoring CustomFields/CustomFieldChoice.php : indentation
This commit is contained in:
parent
4abb994725
commit
23438926b1
@ -40,43 +40,42 @@ use Symfony\Component\Translation\Translator;
|
|||||||
*/
|
*/
|
||||||
class CustomFieldChoice implements CustomFieldInterface
|
class CustomFieldChoice implements CustomFieldInterface
|
||||||
{
|
{
|
||||||
const ALLOW_OTHER = 'other';
|
const ALLOW_OTHER = 'other';
|
||||||
const OTHER_VALUE_LABEL = 'otherValueLabel';
|
const OTHER_VALUE_LABEL = 'otherValueLabel';
|
||||||
const MULTIPLE = 'multiple';
|
const MULTIPLE = 'multiple';
|
||||||
const EXPANDED = 'expanded';
|
const EXPANDED = 'expanded';
|
||||||
const CHOICES = 'choices';
|
const CHOICES = 'choices';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var RequestStack
|
* @var RequestStack
|
||||||
*/
|
*/
|
||||||
private $requestStack;
|
private $requestStack;
|
||||||
|
|
||||||
private $defaultLocales;
|
private $defaultLocales;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var TwigEngine
|
* @var TwigEngine
|
||||||
*/
|
*/
|
||||||
private $templating;
|
private $templating;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
* @var TranslatableStringHelper Helper that find the string in current locale from an array of translation
|
||||||
*/
|
*/
|
||||||
private $translatableStringHelper;
|
private $translatableStringHelper;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
RequestStack $requestStack,
|
RequestStack $requestStack,
|
||||||
Translator $translator,
|
Translator $translator,
|
||||||
TwigEngine $templating,
|
TwigEngine $templating,
|
||||||
TranslatableStringHelper $translatableStringHelper
|
TranslatableStringHelper $translatableStringHelper)
|
||||||
)
|
{
|
||||||
{
|
$this->requestStack = $requestStack;
|
||||||
$this->requestStack = $requestStack;
|
$this->defaultLocales = $translator->getFallbackLocales();
|
||||||
$this->defaultLocales = $translator->getFallbackLocales();
|
$this->templating = $templating;
|
||||||
$this->templating = $templating;
|
|
||||||
$this->translatableStringHelper = $translatableStringHelper;
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
||||||
{
|
{
|
||||||
@ -93,11 +92,10 @@ class CustomFieldChoice implements CustomFieldInterface
|
|||||||
|
|
||||||
//prepare $options
|
//prepare $options
|
||||||
$options = array(
|
$options = array(
|
||||||
'multiple' => $customFieldOptions[self::MULTIPLE],
|
'multiple' => $customFieldOptions[self::MULTIPLE],
|
||||||
'choices' => $choices,
|
'choices' => $choices,
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'label' => $this->translatableStringHelper->localize($customField->getName())
|
'label' => $this->translatableStringHelper->localize($customField->getName()));
|
||||||
);
|
|
||||||
|
|
||||||
//if allow_other = true
|
//if allow_other = true
|
||||||
if ($customFieldOptions[self::ALLOW_OTHER] == true) {
|
if ($customFieldOptions[self::ALLOW_OTHER] == true) {
|
||||||
@ -131,30 +129,28 @@ class CustomFieldChoice implements CustomFieldInterface
|
|||||||
|
|
||||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||||
{
|
{
|
||||||
$builder->add(self::MULTIPLE, 'choice', array(
|
$builder
|
||||||
'expanded' => true,
|
->add(self::MULTIPLE, 'choice', array(
|
||||||
'multiple' => false,
|
'expanded' => true,
|
||||||
'choices' => array(
|
'multiple' => false,
|
||||||
1 => 'Multiple',
|
'choices' => array(
|
||||||
0 => 'Unique'
|
1 => 'Multiple',
|
||||||
),
|
0 => 'Unique'),
|
||||||
'empty_data' => 0
|
'empty_data' => 0
|
||||||
))
|
))
|
||||||
->add(self::EXPANDED, 'choice', array(
|
->add(self::EXPANDED, 'choice', array(
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false,
|
'multiple' => false,
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
1 => 'Expanded',
|
1 => 'Expanded',
|
||||||
0 => 'Non expanded'
|
0 => 'Non expanded'),
|
||||||
),
|
|
||||||
'empty_data' => 0
|
'empty_data' => 0
|
||||||
))
|
))
|
||||||
->add(self::ALLOW_OTHER, 'choice', array(
|
->add(self::ALLOW_OTHER, 'choice', array(
|
||||||
'label' => 'Allow other',
|
'label' => 'Allow other',
|
||||||
'choices' => array(
|
'choices' => array(
|
||||||
0 => 'No',
|
0 => 'No',
|
||||||
1 => 'Yes'
|
1 => 'Yes'),
|
||||||
),
|
|
||||||
'empty_data' => 0,
|
'empty_data' => 0,
|
||||||
'expanded' => true,
|
'expanded' => true,
|
||||||
'multiple' => false
|
'multiple' => false
|
||||||
@ -164,8 +160,7 @@ class CustomFieldChoice implements CustomFieldInterface
|
|||||||
->add(self::CHOICES, new ChoicesType(), array(
|
->add(self::CHOICES, new ChoicesType(), array(
|
||||||
'type' => new ChoicesListType($this->defaultLocales),
|
'type' => new ChoicesListType($this->defaultLocales),
|
||||||
'allow_add' => true
|
'allow_add' => true
|
||||||
))
|
));
|
||||||
;
|
|
||||||
|
|
||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user