16
16
use Symfony \Component \Form \FormBuilderInterface ;
17
17
use Symfony \Component \Form \FormView ;
18
18
use Symfony \Component \Form \FormInterface ;
19
- use Symfony \Component \OptionsResolver \OptionsResolverInterface ;
19
+ use Symfony \Component \OptionsResolver \OptionsResolver ;
20
20
use Symfony \Component \OptionsResolver \Options ;
21
21
22
22
/**
28
28
class Select2Type extends AbstractType
29
29
{
30
30
private $ widget ;
31
-
31
+
32
32
private $ configs ;
33
33
34
34
public function __construct ($ widget , array $ configs = array ())
@@ -68,19 +68,20 @@ public function buildView(FormView $view, FormInterface $form, array $options)
68
68
/**
69
69
* {@inheritdoc}
70
70
*/
71
- public function setDefaultOptions ( OptionsResolverInterface $ resolver )
71
+ public function configureOptions ( OptionsResolver $ resolver )
72
72
{
73
73
$ defaults = $ this ->configs ;
74
74
$ resolver
75
75
->setDefaults (array (
76
76
'configs ' => $ defaults ,
77
77
'transformer ' => null ,
78
78
))
79
- ->setNormalizers (array (
80
- 'configs ' => function (Options $ options , $ configs ) use ($ defaults ) {
79
+ ->setNormalizer (
80
+ 'configs ' ,
81
+ function (Options $ options , $ configs ) use ($ defaults ) {
81
82
return array_merge ($ defaults , $ configs );
82
- },
83
- ))
83
+ }
84
+ )
84
85
;
85
86
}
86
87
@@ -89,13 +90,16 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
89
90
*/
90
91
public function getParent ()
91
92
{
92
- return $ this ->widget ;
93
+ if (class_exists ('Symfony\Component\Form\Extension\Core\Type \\' . ucfirst ($ this ->widget ) . 'Type ' )) {
94
+ return 'Symfony\Component\Form\Extension\Core\Type \\' . ucfirst ($ this ->widget ) . 'Type ' ;
95
+ }
96
+ return 'Symfony\Bridge\Doctrine\Form\Type \\' . ucfirst ($ this ->widget ) . 'Type ' ;
93
97
}
94
98
95
99
/**
96
100
* {@inheritdoc}
97
101
*/
98
- public function getName ()
102
+ public function getBlockPrefix ()
99
103
{
100
104
return 'genemu_jqueryselect2_ ' . $ this ->widget ;
101
105
}
0 commit comments