Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport deprecation changes for Bootstrap 2 #1158

Open
wants to merge 10 commits into
base: v2.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 45 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,53 @@
language: php

sudo: false

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

env:
- SYMFONY_VERSION=v2.0.17
- SYMFONY_VERSION=v2.1.13
- SYMFONY_VERSION=v2.2.11
- SYMFONY_VERSION=v2.3.42
- SYMFONY_VERSION=v2.4.10
- SYMFONY_VERSION=v2.5.12
- SYMFONY_VERSION=v2.6.13
- SYMFONY_VERSION=v2.7.14
- SYMFONY_VERSION=v2.8.7
- SYMFONY_VERSION=v3.0.7
- SYMFONY_VERSION=v3.1.0
- SYMFONY_VERSION=origin/master

before_script: php Tests/tests/vendors.php
script: phpunit
- SYMFONY_VERSION=2.3.* NO_PHPUNIT_BRIDGE=1
- SYMFONY_VERSION=2.4.* NO_PHPUNIT_BRIDGE=1
- SYMFONY_VERSION=2.5.* NO_PHPUNIT_BRIDGE=1
- SYMFONY_VERSION=2.6.* SYMFONY_DEPRECATIONS_HELPER=weak
- SYMFONY_VERSION=2.7.*
- SYMFONY_VERSION=2.8.*
- SYMFONY_VERSION=3.0.*
- SYMFONY_VERSION=3.1.*
- SYMFONY_VERSION=dev-master

matrix:
exclude:
- php: 5.3
env: SYMFONY_VERSION=3.0.*
- php: 5.3
env: SYMFONY_VERSION=3.1.*
- php: 5.3
env: SYMFONY_VERSION=dev-master
- php: 5.4
env: SYMFONY_VERSION=3.0.*
- php: 5.4
env: SYMFONY_VERSION=3.1.*
- php: 5.4
env: SYMFONY_VERSION=dev-master

cache:
directories:
- $HOME/.composer/cache

before_script:
- composer selfupdate
- if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update; fi;
- if [ "$NO_PHPUNIT_BRIDGE" == "" ]; then composer require symfony/phpunit-bridge; fi;
- composer update --prefer-dist $COMPOSER_FLAGS

script:
- vendor/bin/phpunit

after_success:
- coveralls
28 changes: 24 additions & 4 deletions Form/Extension/DateTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class DateTypeExtension extends AbstractTypeExtension
{
Expand All @@ -24,16 +25,35 @@ public function finishView(FormView $view, FormInterface $form, array $options)
}

}

public function setDefaultOptions(OptionsResolverInterface $resolver)

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setOptional(array(
'datepicker'
));
}

/**
* {@inheritdoc}
*
* @deprecated Remove it when bumping requirements to SF 2.7+
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return 'date';
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\DateType'
: 'date' // SF <2.8 BC
;
}
}
36 changes: 29 additions & 7 deletions Form/Extension/ErrorTypeFormTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,55 @@
<?php
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class ErrorTypeFormTypeExtension extends AbstractTypeExtension
{
protected $error_type;
protected $errorType;

public function __construct(array $options)
{
$this->error_type = $options['error_type'];
$this->errorType = $options['error_type'];
}
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['error_type'] = $options['error_type'];
$view->vars['error_delay'] = $options['error_delay'];
}

/**
* {@inheritdoc}
*
* @deprecated 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(
'error_type' => $this->error_type,
'error_delay'=> false
));
'error_type' => $this->errorType,
'error_delay' => false,
));
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return 'form';
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
: 'form' // SF <2.8 BC
;
}
}
30 changes: 25 additions & 5 deletions Form/Extension/HelpFormTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<?php
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\Form\AbstractTypeExtension;
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;

class HelpFormTypeExtension extends AbstractTypeExtension
{
Expand All @@ -24,7 +25,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['help_inline'] = $options['help_inline'];
$view->vars['help_block'] = $options['help_block'];
$view->vars['help_label'] = $options['help_label'];

if (!isset($options['help_label_tooltip']['icon']) && !is_null($this->options['tooltip_icon'])) {
$options['help_label_tooltip']['icon'] = $this->options['tooltip_icon'];
}
Expand Down Expand Up @@ -65,7 +66,10 @@ public function buildView(FormView $view, FormInterface $form, array $options)
}
}

public function setDefaultOptions(OptionsResolverInterface $resolver)
/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'help_inline' => null,
Expand All @@ -85,8 +89,24 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
));
}

/**
* {@inheritdoc}
*
* @deprecated Remove it when bumping requirements to SF 2.7+
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return 'form';
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
: 'form' // SF <2.8 BC
;
}
}
30 changes: 22 additions & 8 deletions Form/Extension/IconButtonExtension.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,29 @@
<?php
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\Form\Extension\Core\Type\ButtonType;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class IconButtonExtension extends AbstractTypeExtension
{
/**
* {@inheritdoc}
*/
public function getExtendedType()
public function buildView(FormView $view, FormInterface $form, array $options)
{
return 'button';
$view->vars['icon'] = $options['icon'];
$view->vars['icon_color'] = $options['icon_color'];
}

/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(
array(
Expand All @@ -33,10 +35,22 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)

/**
* {@inheritdoc}
*
* @deprecated Remove it when bumping requirements to SF 2.7+
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$view->vars['icon'] = $options['icon'];
$view->vars['icon_color'] = $options['icon_color'];
$this->configureOptions($resolver);
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\ButtonType'
: 'button' // SF <2.8 BC
;
}
}
28 changes: 25 additions & 3 deletions Form/Extension/LegendFormTypeExtension.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<?php
namespace Mopa\Bundle\BootstrapBundle\Form\Extension;

use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;

class LegendFormTypeExtension extends AbstractTypeExtension
{
Expand Down Expand Up @@ -35,7 +36,11 @@ public function buildView(FormView $view, FormInterface $form, array $options)
$view->vars['render_optional_text'] = $options['render_optional_text'];
$view->vars['errors_on_forms'] = $options['errors_on_forms'];
}
public function setDefaultOptions(OptionsResolverInterface $resolver)

/**
* {@inheritdoc}
*/
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'render_fieldset' => $this->render_fieldset,
Expand All @@ -47,8 +52,25 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
'errors_on_forms' => $this->errors_on_forms,
));
}

/**
* {@inheritdoc}
*
* @deprecated Remove it when bumping requirements to SF 2.7+
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$this->configureOptions($resolver);
}

/**
* {@inheritdoc}
*/
public function getExtendedType()
{
return 'form';
return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
: 'form' // SF <2.8 BC
;
}
}
Loading