From 6ecace0babd0012ce84478b52872600ee546216b Mon Sep 17 00:00:00 2001 From: Sullivan SENECHAL Date: Mon, 20 Apr 2015 12:56:37 +0200 Subject: [PATCH] Fix deprecated forms setDefaultOptions method --- Form/Core/Type/CaptchaType.php | 14 +++++++++++++- Form/Core/Type/PlainType.php | 14 +++++++++++++- Form/Core/Type/ReCaptchaType.php | 12 ++++++++++++ Form/Core/Type/TinymceType.php | 12 ++++++++++++ Form/Doctrine/Type/AjaxDocumentType.php | 14 +++++++++++++- Form/Doctrine/Type/AjaxEntityType.php | 14 +++++++++++++- Form/JQuery/Type/AutocompleteType.php | 12 ++++++++++++ Form/JQuery/Type/AutocompleterType.php | 14 +++++++++++++- Form/JQuery/Type/ChosenType.php | 12 ++++++++++++ Form/JQuery/Type/ColorType.php | 12 ++++++++++++ Form/JQuery/Type/DateType.php | 16 ++++++++++++++-- Form/JQuery/Type/FileType.php | 14 +++++++++++++- Form/JQuery/Type/GeolocationType.php | 14 +++++++++++++- Form/JQuery/Type/ImageType.php | 14 +++++++++++++- Form/JQuery/Type/RatingType.php | 12 ++++++++++++ Form/JQuery/Type/Select2Type.php | 16 ++++++++++++++-- Form/JQuery/Type/SliderType.php | 15 +++++++++++++++ Form/JQuery/Type/TokeninputType.php | 14 +++++++++++++- Form/Model/Type/AjaxModelType.php | 14 +++++++++++++- 19 files changed, 245 insertions(+), 14 deletions(-) diff --git a/Form/Core/Type/CaptchaType.php b/Form/Core/Type/CaptchaType.php index 654db58c..af36b138 100644 --- a/Form/Core/Type/CaptchaType.php +++ b/Form/Core/Type/CaptchaType.php @@ -15,10 +15,12 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Gd\Type\Captcha; use Genemu\Bundle\FormBundle\Form\Core\Validator\CaptchaValidator; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * CaptchaType @@ -72,8 +74,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $defaults = array_merge( array('attr' => array('autocomplete' => 'off')), diff --git a/Form/Core/Type/PlainType.php b/Form/Core/Type/PlainType.php index 81c7af5c..c0dad2ae 100644 --- a/Form/Core/Type/PlainType.php +++ b/Form/Core/Type/PlainType.php @@ -6,9 +6,11 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Symfony\Component\Form\Extension\Core\Type\DateType; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * A Form type that just renders the field as a p tag. This is useful for forms where certain field @@ -20,8 +22,18 @@ class PlainType extends AbstractType { /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'widget' => 'field', diff --git a/Form/Core/Type/ReCaptchaType.php b/Form/Core/Type/ReCaptchaType.php index e32f298a..5284747e 100644 --- a/Form/Core/Type/ReCaptchaType.php +++ b/Form/Core/Type/ReCaptchaType.php @@ -18,8 +18,10 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\Exception\FormException; use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * ReCaptchaType * @@ -79,8 +81,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $configs = array_merge(array( 'lang' => \Locale::getDefault(), diff --git a/Form/Core/Type/TinymceType.php b/Form/Core/Type/TinymceType.php index dfd8cd03..47785ef7 100644 --- a/Form/Core/Type/TinymceType.php +++ b/Form/Core/Type/TinymceType.php @@ -15,8 +15,10 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * TinymceType * @@ -46,8 +48,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $configs = array_merge(array( 'language' => \Locale::getDefault(), diff --git a/Form/Doctrine/Type/AjaxDocumentType.php b/Form/Doctrine/Type/AjaxDocumentType.php index c97d7803..c55180fc 100644 --- a/Form/Doctrine/Type/AjaxDocumentType.php +++ b/Form/Doctrine/Type/AjaxDocumentType.php @@ -15,8 +15,10 @@ use Doctrine\Common\Persistence\ManagerRegistry; use Genemu\Bundle\FormBundle\Form\Doctrine\ChoiceList\AjaxEntityChoiceList; use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * AjaxDocumentType * @@ -36,10 +38,20 @@ public function __construct(ManagerRegistry $registry) $this->registry = $registry; } - /** + /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'document_manager' => null, diff --git a/Form/Doctrine/Type/AjaxEntityType.php b/Form/Doctrine/Type/AjaxEntityType.php index ef49fd89..01ac230a 100644 --- a/Form/Doctrine/Type/AjaxEntityType.php +++ b/Form/Doctrine/Type/AjaxEntityType.php @@ -13,11 +13,13 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Doctrine\Common\Persistence\ManagerRegistry; use Genemu\Bundle\FormBundle\Form\Doctrine\ChoiceList\AjaxEntityChoiceList; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * AjaxEntityType @@ -40,8 +42,18 @@ public function __construct(ManagerRegistry $registry) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $registry = $this->registry; diff --git a/Form/JQuery/Type/AutocompleteType.php b/Form/JQuery/Type/AutocompleteType.php index a9b7731d..aa6bf4a6 100644 --- a/Form/JQuery/Type/AutocompleteType.php +++ b/Form/JQuery/Type/AutocompleteType.php @@ -17,6 +17,8 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Symfony\Component\OptionsResolver\OptionsResolverInterface; use Symfony\Component\PropertyAccess\PropertyPath; use Symfony\Component\PropertyAccess\PropertyAccess; @@ -58,8 +60,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $type = $this->type; $registry = $this->registry; diff --git a/Form/JQuery/Type/AutocompleterType.php b/Form/JQuery/Type/AutocompleterType.php index 12e7945c..2022bac1 100644 --- a/Form/JQuery/Type/AutocompleterType.php +++ b/Form/JQuery/Type/AutocompleterType.php @@ -16,10 +16,12 @@ use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Form\Core\ChoiceList\AjaxSimpleChoiceList; use Genemu\Bundle\FormBundle\Form\Core\DataTransformer\ChoiceToJsonTransformer; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * @author Olivier Chauvel @@ -81,8 +83,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $widget = $this->widget; diff --git a/Form/JQuery/Type/ChosenType.php b/Form/JQuery/Type/ChosenType.php index cfa43da7..03213913 100644 --- a/Form/JQuery/Type/ChosenType.php +++ b/Form/JQuery/Type/ChosenType.php @@ -15,8 +15,10 @@ use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * ChosenType to JQueryLib * @@ -52,8 +54,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefaults(array( diff --git a/Form/JQuery/Type/ColorType.php b/Form/JQuery/Type/ColorType.php index 236a2bcc..63ece06f 100644 --- a/Form/JQuery/Type/ColorType.php +++ b/Form/JQuery/Type/ColorType.php @@ -15,8 +15,10 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * ColorType * @@ -35,8 +37,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefaults(array( diff --git a/Form/JQuery/Type/DateType.php b/Form/JQuery/Type/DateType.php index f16dee2b..21a8be09 100644 --- a/Form/JQuery/Type/DateType.php +++ b/Form/JQuery/Type/DateType.php @@ -15,8 +15,10 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Symfony\Component\Form\Extension\Core\Type\DateType as BaseDateType; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * DateType @@ -36,7 +38,7 @@ public function __construct(array $options) { $this->options = $options; } - + /** * {@inheritdoc} */ @@ -75,8 +77,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $configs = $this->options; diff --git a/Form/JQuery/Type/FileType.php b/Form/JQuery/Type/FileType.php index b0771dfc..baec0c23 100644 --- a/Form/JQuery/Type/FileType.php +++ b/Form/JQuery/Type/FileType.php @@ -17,10 +17,12 @@ use Symfony\Component\Form\FormInterface; use Symfony\Component\HttpFoundation\File\File; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Form\Core\EventListener\FileListener; use Genemu\Bundle\FormBundle\Form\JQuery\DataTransformer\FileToValueTransformer; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * FileType @@ -74,8 +76,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $configs = $this->options; diff --git a/Form/JQuery/Type/GeolocationType.php b/Form/JQuery/Type/GeolocationType.php index 9e9fa80d..eeba0c71 100644 --- a/Form/JQuery/Type/GeolocationType.php +++ b/Form/JQuery/Type/GeolocationType.php @@ -15,9 +15,11 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Form\Core\EventListener\GeolocationListener; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * GeolocationType to JQueryLib @@ -64,8 +66,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'map' => false, diff --git a/Form/JQuery/Type/ImageType.php b/Form/JQuery/Type/ImageType.php index 3de3bea7..9db33d02 100644 --- a/Form/JQuery/Type/ImageType.php +++ b/Form/JQuery/Type/ImageType.php @@ -14,9 +14,11 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Gd\File\Image; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * ImageType @@ -81,8 +83,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'configs' => array( diff --git a/Form/JQuery/Type/RatingType.php b/Form/JQuery/Type/RatingType.php index 01d0dd30..b28b3a8d 100644 --- a/Form/JQuery/Type/RatingType.php +++ b/Form/JQuery/Type/RatingType.php @@ -16,8 +16,10 @@ use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * RatingType * @@ -47,8 +49,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'number' => 5, diff --git a/Form/JQuery/Type/Select2Type.php b/Form/JQuery/Type/Select2Type.php index 595a31ce..f904d8f2 100644 --- a/Form/JQuery/Type/Select2Type.php +++ b/Form/JQuery/Type/Select2Type.php @@ -16,8 +16,10 @@ use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Symfony\Component\OptionsResolver\Options; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * Select2Type to JQueryLib @@ -28,7 +30,7 @@ class Select2Type extends AbstractType { private $widget; - + private $configs; public function __construct($widget, array $configs = array()) @@ -67,8 +69,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $defaults = $this->configs; $resolver diff --git a/Form/JQuery/Type/SliderType.php b/Form/JQuery/Type/SliderType.php index 7fc677a4..7746f2db 100644 --- a/Form/JQuery/Type/SliderType.php +++ b/Form/JQuery/Type/SliderType.php @@ -14,8 +14,10 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormView; +use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolverInterface; + /** * SliderType * @@ -31,7 +33,20 @@ public function buildView(FormView $view, FormInterface $form, array $options) $view->vars['configs'] = $options; } + /** + * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ + */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'min' => 0, diff --git a/Form/JQuery/Type/TokeninputType.php b/Form/JQuery/Type/TokeninputType.php index cf87b9ca..f279a70c 100644 --- a/Form/JQuery/Type/TokeninputType.php +++ b/Form/JQuery/Type/TokeninputType.php @@ -16,10 +16,12 @@ use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Form\Core\ChoiceList\AjaxSimpleChoiceList; use Genemu\Bundle\FormBundle\Form\Core\DataTransformer\ChoiceToJsonTransformer; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * @author Adam KuĊ›mierz @@ -89,8 +91,18 @@ public function buildView(FormView $view, FormInterface $form, array $options) /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $widget = $this->widget; diff --git a/Form/Model/Type/AjaxModelType.php b/Form/Model/Type/AjaxModelType.php index bc2fa892..4e03ae22 100644 --- a/Form/Model/Type/AjaxModelType.php +++ b/Form/Model/Type/AjaxModelType.php @@ -13,9 +13,11 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; +use Symfony\Component\OptionsResolver\OptionsResolver; + use Genemu\Bundle\FormBundle\Form\Model\ChoiceList\AjaxModelChoiceList; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; /** * AjaxModelType @@ -26,8 +28,18 @@ class AjaxModelType extends AbstractType { /** * {@inheritdoc} + * + * @todo Remove it when bumping requirements to SF 2.7+ */ public function setDefaultOptions(OptionsResolverInterface $resolver) + { + $this->configureOptions($resolver); + } + + /** + * {@inheritdoc} + */ + public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'template' => 'choice',