Skip to content

Commit e6efcd4

Browse files
authored
Merge pull request propelorm#475 from romantymoshyk/patch-2
Fixed incompatibility with PropelChoiceLoader constructor
2 parents b3f2f91 + d30e7d1 commit e6efcd4

1 file changed

Lines changed: 4 additions & 24 deletions

File tree

Form/Type/ModelType.php

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
use Propel\Bundle\PropelBundle\Form\ChoiceList\PropelChoiceLoader;
1515
use Propel\Bundle\PropelBundle\Form\DataTransformer\CollectionToArrayTransformer;
1616
use Symfony\Component\Form\AbstractType;
17-
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
18-
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
19-
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
2017
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
2118
use Symfony\Component\Form\FormBuilderInterface;
2219
use Symfony\Component\OptionsResolver\Options;
@@ -37,7 +34,7 @@
3734
* public function buildForm(FormBuilderInterface $builder, array $options)
3835
* {
3936
* $builder
40-
* ->add('product', 'model', array(
37+
* ->add('product', ModelType::class, array(
4138
* 'class' => 'Model\Product',
4239
* 'query' => ProductQuery::create()
4340
* ->filterIsActive(true)
@@ -55,25 +52,6 @@
5552
*/
5653
class ModelType extends AbstractType
5754
{
58-
/**
59-
* @var ChoiceListFactoryInterface
60-
*/
61-
private $choiceListFactory;
62-
63-
/**
64-
* ModelType constructor.
65-
*
66-
* @param PropertyAccessorInterface|null $propertyAccessor
67-
* @param ChoiceListFactoryInterface|null $choiceListFactory
68-
*/
69-
public function __construct(PropertyAccessorInterface $propertyAccessor = null, ChoiceListFactoryInterface $choiceListFactory = null)
70-
{
71-
$this->choiceListFactory = $choiceListFactory ?: new PropertyAccessDecorator(
72-
new DefaultChoiceListFactory(),
73-
$propertyAccessor
74-
);
75-
}
76-
7755
/**
7856
* Creates the label for a choice.
7957
*
@@ -133,7 +111,6 @@ public function configureOptions(OptionsResolver $resolver)
133111
if (null === $options['choices']) {
134112

135113
$propelChoiceLoader = new PropelChoiceLoader(
136-
$this->choiceListFactory,
137114
$options['class'],
138115
$options['query']
139116
);
@@ -252,6 +229,9 @@ public function getBlockPrefix()
252229
return 'model';
253230
}
254231

232+
/**
233+
* {@inheritdoc}
234+
*/
255235
public function getParent()
256236
{
257237
return ChoiceType::class;

0 commit comments

Comments
 (0)