Skip to content

Commit 395bb11

Browse files
authored
Fix deprecations SF4 (phiamo#1242)
* Fix form extension deprecations form Symfony 4 and some others.
1 parent 00696d9 commit 395bb11

16 files changed

+240
-103
lines changed

DependencyInjection/Configuration.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@
1717

1818
class Configuration implements ConfigurationInterface
1919
{
20+
const KEY = 'mopa_bootstrap';
21+
2022
/**
2123
* {@inheritdoc}
2224
*/
2325
public function getConfigTreeBuilder()
2426
{
25-
$treeBuilder = new TreeBuilder();
26-
$rootNode = $treeBuilder->root('mopa_bootstrap');
27+
$treeBuilder = new TreeBuilder(self::KEY);
28+
$rootNode = $treeBuilder->root(self::KEY);
2729
$this->addFormConfig($rootNode);
2830
$this->addIconsConfig($rootNode);
2931
$this->addMenuConfig($rootNode);

Form/Extension/DateTypeExtension.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\DateType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -94,8 +95,18 @@ public function configureOptions(OptionsResolver $resolver)
9495
public function getExtendedType()
9596
{
9697
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
97-
? 'Symfony\Component\Form\Extension\Core\Type\DateType'
98+
? DateType::class
9899
: 'date' // SF <2.8 BC
99100
;
100101
}
102+
103+
/**
104+
* @inheritdoc
105+
*/
106+
public static function getExtendedTypes()
107+
{
108+
return [
109+
DateType::class,
110+
];
111+
}
101112
}

Form/Extension/DatetimeTypeExtension.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -73,8 +74,18 @@ public function configureOptions(OptionsResolver $resolver)
7374
public function getExtendedType()
7475
{
7576
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
76-
? 'Symfony\Component\Form\Extension\Core\Type\DateTimeType'
77+
? DateTimeType::class
7778
: 'datetime' // SF <2.8 BC
7879
;
7980
}
81+
82+
/**
83+
* @inheritdoc
84+
*/
85+
public static function getExtendedTypes()
86+
{
87+
return [
88+
DateTimeType::class,
89+
];
90+
}
8091
}

Form/Extension/EmbedFormExtension.php

+22-11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

14+
use Symfony\Component\Form\Extension\Core\Type\FormType;
1415
use Symfony\Component\OptionsResolver\OptionsResolver;
1516
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
1617
use Symfony\Component\Form\AbstractTypeExtension;
@@ -24,17 +25,6 @@
2425
*/
2526
class EmbedFormExtension extends AbstractTypeExtension
2627
{
27-
/**
28-
* {@inheritdoc}
29-
*/
30-
public function getExtendedType()
31-
{
32-
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
33-
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
34-
: 'form' // SF <2.8 BC
35-
;
36-
}
37-
3828
/**
3929
* {@inheritdoc}
4030
*
@@ -63,4 +53,25 @@ public function buildView(FormView $view, FormInterface $form, array $options)
6353
{
6454
$view->vars['embed_form'] = $options['embed_form'];
6555
}
56+
57+
/**
58+
* {@inheritdoc}
59+
*/
60+
public function getExtendedType()
61+
{
62+
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
63+
? FormType::class
64+
: 'form' // SF <2.8 BC
65+
;
66+
}
67+
68+
/**
69+
* @inheritdoc
70+
*/
71+
public static function getExtendedTypes()
72+
{
73+
return [
74+
FormType::class,
75+
];
76+
}
6677
}

Form/Extension/ErrorTypeFormTypeExtension.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\FormType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -75,8 +76,18 @@ public function configureOptions(OptionsResolver $resolver)
7576
public function getExtendedType()
7677
{
7778
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
78-
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
79+
? FormType::class
7980
: 'form' // SF <2.8 BC
8081
;
8182
}
83+
84+
/**
85+
* @inheritdoc
86+
*/
87+
public static function getExtendedTypes()
88+
{
89+
return [
90+
FormType::class,
91+
];
92+
}
8293
}

Form/Extension/HelpFormTypeExtension.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
1515
use Symfony\Component\Form\Exception\InvalidArgumentException;
16+
use Symfony\Component\Form\Extension\Core\Type\FormType;
1617
use Symfony\Component\Form\FormInterface;
1718
use Symfony\Component\Form\FormView;
1819
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -192,8 +193,18 @@ public function configureOptions(OptionsResolver $resolver)
192193
public function getExtendedType()
193194
{
194195
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
195-
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
196+
? FormType::class
196197
: 'form' // SF <2.8 BC
197198
;
198199
}
200+
201+
/**
202+
* @inheritdoc
203+
*/
204+
public static function getExtendedTypes()
205+
{
206+
return [
207+
FormType::class,
208+
];
209+
}
199210
}

Form/Extension/IconButtonExtension.php

+22-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -24,17 +25,6 @@
2425
*/
2526
class IconButtonExtension extends AbstractTypeExtension
2627
{
27-
/**
28-
* {@inheritdoc}
29-
*/
30-
public function getExtendedType()
31-
{
32-
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
33-
? 'Symfony\Component\Form\Extension\Core\Type\ButtonType'
34-
: 'button' // SF <2.8 BC
35-
;
36-
}
37-
3828
/**
3929
* {@inheritdoc}
4030
*
@@ -64,4 +54,25 @@ public function buildView(FormView $view, FormInterface $form, array $options)
6454
$view->vars['icon'] = $options['icon'];
6555
$view->vars['icon_inverted'] = $options['icon_inverted'];
6656
}
57+
58+
/**
59+
* {@inheritdoc}
60+
*/
61+
public function getExtendedType()
62+
{
63+
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
64+
? ButtonType::class
65+
: 'form' // SF <2.8 BC
66+
;
67+
}
68+
69+
/**
70+
* @inheritdoc
71+
*/
72+
public static function getExtendedTypes()
73+
{
74+
return [
75+
ButtonType::class,
76+
];
77+
}
6778
}

Form/Extension/LayoutFormTypeExtension.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\FormType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\Options;
@@ -119,8 +120,18 @@ public function configureOptions(OptionsResolver $resolver)
119120
public function getExtendedType()
120121
{
121122
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
122-
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
123+
? FormType::class
123124
: 'form' // SF <2.8 BC
124125
;
125126
}
127+
128+
/**
129+
* @inheritdoc
130+
*/
131+
public static function getExtendedTypes()
132+
{
133+
return [
134+
FormType::class,
135+
];
136+
}
126137
}

Form/Extension/LegendFormTypeExtension.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\FormType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -92,8 +93,18 @@ public function configureOptions(OptionsResolver $resolver)
9293
public function getExtendedType()
9394
{
9495
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
95-
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
96+
? FormType::class
9697
: 'form' // SF <2.8 BC
9798
;
9899
}
100+
101+
/**
102+
* @inheritdoc
103+
*/
104+
public static function getExtendedTypes()
105+
{
106+
return [
107+
FormType::class,
108+
];
109+
}
99110
}

Form/Extension/OffsetButtonExtension.php

+22-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -24,17 +25,6 @@
2425
*/
2526
class OffsetButtonExtension extends AbstractTypeExtension
2627
{
27-
/**
28-
* {@inheritdoc}
29-
*/
30-
public function getExtendedType()
31-
{
32-
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
33-
? 'Symfony\Component\Form\Extension\Core\Type\ButtonType'
34-
: 'button' // SF <2.8 BC
35-
;
36-
}
37-
3828
/**
3929
* {@inheritdoc}
4030
*
@@ -62,4 +52,25 @@ public function buildView(FormView $view, FormInterface $form, array $options)
6252
{
6353
$view->vars['button_offset'] = $options['button_offset'];
6454
}
55+
56+
/**
57+
* {@inheritdoc}
58+
*/
59+
public function getExtendedType()
60+
{
61+
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
62+
? ButtonType::class
63+
: 'form' // SF <2.8 BC
64+
;
65+
}
66+
67+
/**
68+
* @inheritdoc
69+
*/
70+
public static function getExtendedTypes()
71+
{
72+
return [
73+
ButtonType::class,
74+
];
75+
}
6576
}

Form/Extension/StaticTextExtension.php

+22-11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
15+
use Symfony\Component\Form\Extension\Core\Type\FormType;
1516
use Symfony\Component\Form\FormInterface;
1617
use Symfony\Component\Form\FormView;
1718
use Symfony\Component\OptionsResolver\OptionsResolver;
@@ -24,17 +25,6 @@
2425
*/
2526
class StaticTextExtension extends AbstractTypeExtension
2627
{
27-
/**
28-
* {@inheritdoc}
29-
*/
30-
public function getExtendedType()
31-
{
32-
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
33-
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
34-
: 'form' // SF <2.8 BC
35-
;
36-
}
37-
3828
/**
3929
* {@inheritdoc}
4030
*
@@ -67,4 +57,25 @@ public function buildView(FormView $view, FormInterface $form, array $options)
6757
$view->vars['disabled'] = true;
6858
}
6959
}
60+
61+
/**
62+
* {@inheritdoc}
63+
*/
64+
public function getExtendedType()
65+
{
66+
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
67+
? FormType::class
68+
: 'form' // SF <2.8 BC
69+
;
70+
}
71+
72+
/**
73+
* @inheritdoc
74+
*/
75+
public static function getExtendedTypes()
76+
{
77+
return [
78+
FormType::class,
79+
];
80+
}
7081
}

0 commit comments

Comments
 (0)