Skip to content

Commit 1070332

Browse files
author
Leny BERNARD
committed
symfony v3 compatibility (form type)
1 parent 975288f commit 1070332

3 files changed

Lines changed: 25 additions & 39 deletions

File tree

Form/WidgetButtonType.php

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
namespace Victoire\Widget\ButtonBundle\Form;
44

5+
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
56
use Symfony\Component\Form\FormBuilderInterface;
6-
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
7+
use Symfony\Component\OptionsResolver\OptionsResolver;
78
use Victoire\Bundle\CoreBundle\Form\WidgetType;
9+
use Victoire\Bundle\FormBundle\Form\Type\FontAwesomePickerType;
10+
use Victoire\Bundle\FormBundle\Form\Type\LinkType;
811

912
/**
1013
* WidgetButton form type.
@@ -29,7 +32,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2932
->add('hoverTitle', null, [
3033
'label' => 'widget.button.form.label.hoverTitle',
3134
])
32-
->add('size', 'choice', [
35+
->add('size', ChoiceType::class, [
3336
'label' => 'widget.button.form.label.size',
3437
'choices' => [
3538
'md' => 'widget.button.form.choice.size.normal',
@@ -38,7 +41,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
3841
],
3942
'required' => true,
4043
])
41-
->add('style', 'choice', [
44+
->add('style', ChoiceType::class, [
4245
'label' => 'widget.button.form.label.style',
4346
'choices' => [
4447
'default' => 'widget.button.form.choice.style.label.default',
@@ -51,7 +54,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
5154
],
5255
'required' => true,
5356
])
54-
->add('link', 'victoire_link')
57+
->add('link', LinkType::class)
5558
->add('isBlock', null, [
5659
'label' => 'widget.button.form.label.isBlock',
5760
])
@@ -61,34 +64,22 @@ public function buildForm(FormBuilderInterface $builder, array $options)
6164
->add('tooltipable', null, [
6265
'label' => 'widget.button.form.label.tooltipable',
6366
])
64-
->add('icon', 'font_awesome_picker');
67+
->add('icon', FontAwesomePickerType::class);
6568

6669
parent::buildForm($builder, $options);
6770
}
6871

6972
/**
70-
* bind form to WidgetButton entity.
71-
*
72-
* @param OptionsResolverInterface $resolver
73+
* {@inheritdoc}
7374
*/
74-
public function setDefaultOptions(OptionsResolverInterface $resolver)
75+
public function configureOptions(OptionsResolver $resolver)
7576
{
76-
parent::setDefaultOptions($resolver);
77+
parent::configureOptions($resolver);
7778

7879
$resolver->setDefaults([
7980
'data_class' => 'Victoire\Widget\ButtonBundle\Entity\WidgetButton',
8081
'widget' => 'Button',
8182
'translation_domain' => 'victoire',
8283
]);
8384
}
84-
85-
/**
86-
* get form name.
87-
*
88-
* @return string
89-
*/
90-
public function getName()
91-
{
92-
return 'victoire_widget_form_button';
93-
}
9485
}

Resources/config/services.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ services:
1010
victoire.widget.form.button:
1111
class: Victoire\Widget\ButtonBundle\Form\WidgetButtonType
1212
tags:
13-
- { name: form.type , alias: victoire_widget_form_button}
14-
13+
- { name: form.type }

composer.json

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,34 @@
11
{
2-
"name" : "friendsofvictoire/button-widget",
3-
"type" : "symfony-bundle",
4-
"description" : "Victoire DCMS Button widget",
5-
"keywords" : [
2+
"name": "friendsofvictoire/button-widget",
3+
"type": "symfony-bundle",
4+
"description": "Victoire DCMS Button widget",
5+
"keywords": [
66
"DCMS",
77
"Victoire",
88
"Button",
99
"widget",
10-
"FoV",
11-
"FriendsofVictoire",
12-
"Dynamic",
13-
"CMS"
10+
"FriendsofVictoire"
1411
],
15-
"homepage" : "http://victoire.io",
16-
"license" : "MIT",
17-
"authors" : [
12+
"license": "MIT",
13+
"authors": [
1814
{
1915
"name" : "Leny BERNARD",
2016
"email": "leny@victoire.io"
2117
}
2218
],
23-
"require" : {
24-
"php" : ">=5.3.3",
19+
"require": {
20+
"php": ">=5.3.3",
2521
"symfony/framework-bundle": "~2.3",
26-
"victoire/victoire" : "~1.3"
22+
"victoire/victoire": "~1.5"
2723
},
28-
"autoload" : {
24+
"autoload": {
2925
"psr-0": {
3026
"Victoire\\Widget\\ButtonBundle": ""
3127
}
3228
},
3329
"minimum-stability": "dev",
34-
"target-dir" : "Victoire/Widget/ButtonBundle",
35-
"extra" : {
30+
"target-dir": "Victoire/Widget/ButtonBundle",
31+
"extra": {
3632
"branch-alias": {
3733
"dev-master": "1.3.x-dev"
3834
}

0 commit comments

Comments
 (0)