Commit 279c7733 authored by Fabien Potencier's avatar Fabien Potencier

bumped min version of Symfony to 2.6 (2.4 and 2.5 are not maintained anymore)

parent eaa5429e
...@@ -2,11 +2,8 @@ language: php ...@@ -2,11 +2,8 @@ language: php
before_script: before_script:
# symfony/* # symfony/*
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.8' ]; then sed -i 's/~2.4/2.8.*@dev/g' composer.json; composer update --dev --prefer-source; fi" - sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.8' ]; then sed -i 's/~2.7/2.8.*@dev/g' composer.json; composer update --dev --prefer-source; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.7' ]; then sed -i 's/~2.4/2.7.*@dev/g' composer.json; composer update --dev --prefer-source; fi" - sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.7' ]; then sed -i 's/~2.6/2.7.*@dev/g' composer.json; composer update --dev --prefer-source; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '' ]; then sed -i 's/~2.4/2.6.*@dev/g' composer.json; composer update --dev --prefer-source; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.5' ]; then sed -i 's/~2.4/2.5.*@dev/g' composer.json; composer update --dev --prefer-source; fi"
- sh -c "if [ '$SYMFONY_DEPS_VERSION' = '2.4' ]; then sed -i 's/~2.4/2.4.*@dev/g' composer.json; composer update --dev --prefer-source; fi"
- composer install --dev --prefer-source - composer install --dev --prefer-source
script: phpunit script: phpunit
...@@ -22,11 +19,6 @@ matrix: ...@@ -22,11 +19,6 @@ matrix:
allow_failures: allow_failures:
- php: hhvm - php: hhvm
include: include:
- php: 5.6
env: SYMFONY_DEPS_VERSION=2.4
- php: 5.6
env: SYMFONY_DEPS_VERSION=2.5
- php: 5.6
env: SYMFONY_DEPS_VERSION=2.7 env: SYMFONY_DEPS_VERSION=2.7
- php: 5.6 - php: 5.6
env: SYMFONY_DEPS_VERSION=2.8 env: SYMFONY_DEPS_VERSION=2.8
...@@ -18,39 +18,39 @@ ...@@ -18,39 +18,39 @@
"require": { "require": {
"php": ">=5.3.9", "php": ">=5.3.9",
"pimple/pimple": "~3.0", "pimple/pimple": "~3.0",
"symfony/event-dispatcher": "~2.4", "symfony/event-dispatcher": "~2.6",
"symfony/http-foundation": "~2.4", "symfony/http-foundation": "~2.6",
"symfony/http-kernel": "~2.4", "symfony/http-kernel": "~2.6",
"symfony/routing": "~2.4" "symfony/routing": "~2.6"
}, },
"require-dev": { "require-dev": {
"symfony/security": "~2.4", "symfony/security": "~2.6",
"symfony/config": "~2.4", "symfony/config": "~2.6",
"symfony/locale": "~2.4", "symfony/locale": "~2.6",
"symfony/form": "~2.4", "symfony/form": "~2.6",
"symfony/browser-kit": "~2.4", "symfony/browser-kit": "~2.6",
"symfony/css-selector": "~2.4", "symfony/css-selector": "~2.6",
"symfony/debug": "~2.4", "symfony/debug": "~2.6",
"symfony/dom-crawler": "~2.4", "symfony/dom-crawler": "~2.6",
"symfony/finder": "~2.4", "symfony/finder": "~2.6",
"symfony/monolog-bridge": "~2.4", "symfony/monolog-bridge": "~2.6",
"symfony/doctrine-bridge": "~2.4", "symfony/doctrine-bridge": "~2.6",
"symfony/options-resolver": "~2.4", "symfony/options-resolver": "~2.6",
"symfony/process": "~2.4", "symfony/process": "~2.6",
"symfony/serializer": "~2.4", "symfony/serializer": "~2.6",
"symfony/translation": "~2.4", "symfony/translation": "~2.6",
"symfony/twig-bridge": "~2.4", "symfony/twig-bridge": "~2.6",
"symfony/validator": "~2.4", "symfony/validator": "~2.6",
"twig/twig": ">=1.8.0,<2.0-dev", "twig/twig": ">=1.8.0,<2.0-dev",
"doctrine/dbal": "~2.2", "doctrine/dbal": "~2.2",
"swiftmailer/swiftmailer": "5.*", "swiftmailer/swiftmailer": "5.*",
"monolog/monolog": "~1.4,>=1.4.1" "monolog/monolog": "~1.4,>=1.4.1"
}, },
"suggest": { "suggest": {
"symfony/browser-kit": "~2.4", "symfony/browser-kit": "~2.6",
"symfony/css-selector": "~2.4", "symfony/css-selector": "~2.6",
"symfony/dom-crawler": "~2.4", "symfony/dom-crawler": "~2.6",
"symfony/form": "~2.4" "symfony/form": "~2.6"
}, },
"replace": { "replace": {
"silex/api": "self.version", "silex/api": "self.version",
......
...@@ -20,9 +20,7 @@ Services ...@@ -20,9 +20,7 @@ Services
that is used for build a form. that is used for build a form.
* **form.csrf_provider**: An instance of an implementation of * **form.csrf_provider**: An instance of an implementation of
`CsrfProviderInterface `CsrfTokenManagerInterface <http://api.symfony.com/2.7/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.html>`_.
<http://api.symfony.com/2.3/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.html>`_ for Symfony 2.3 or
`CsrfTokenManagerInterface <http://api.symfony.com/2.7/Symfony/Component/Security/Csrf/CsrfTokenManagerInterface.html>`_ for Symfony 2.4+.
Registering Registering
----------- -----------
...@@ -67,7 +65,7 @@ Registering ...@@ -67,7 +65,7 @@ Registering
composer require symfony/validator symfony/config symfony/translation composer require symfony/validator symfony/config symfony/translation
The Symfony Security CSRF component is used to protect forms against CSRF The Symfony Security CSRF component is used to protect forms against CSRF
attacks (as of Symfony 2.4+): attacks:
.. code-block:: bash .. code-block:: bash
......
...@@ -4,10 +4,6 @@ HttpFragmentServiceProvider ...@@ -4,10 +4,6 @@ HttpFragmentServiceProvider
The *HttpFragmentServiceProvider* provides support for the Symfony2 fragment The *HttpFragmentServiceProvider* provides support for the Symfony2 fragment
sub-framework, which allows you to embed fragments of HTML in a template. sub-framework, which allows you to embed fragments of HTML in a template.
.. warning::
This service provider only work with Symfony 2.4+.
Parameters Parameters
---------- ----------
......
...@@ -107,19 +107,9 @@ class FormServiceProvider implements ServiceProviderInterface ...@@ -107,19 +107,9 @@ class FormServiceProvider implements ServiceProviderInterface
}; };
$app['form.csrf_provider'] = function ($app) { $app['form.csrf_provider'] = function ($app) {
if (!class_exists('Symfony\Component\Form\Extension\DataCollector\DataCollectorExtension')) { $storage = isset($app['session']) ? new SessionTokenStorage($app['session']) : new NativeSessionTokenStorage();
// Symfony 2.3
if (isset($app['session'])) {
return new SessionCsrfProvider($app['session'], $app['form.secret']);
}
return new DefaultCsrfProvider($app['form.secret']);
} else {
// Symfony 2.4+
$storage = isset($app['session']) ? new SessionTokenStorage($app['session']) : new NativeSessionTokenStorage();
return new CsrfTokenManager(null, $storage); return new CsrfTokenManager(null, $storage);
}
}; };
} }
} }
...@@ -17,7 +17,6 @@ use Silex\Provider\TranslationServiceProvider; ...@@ -17,7 +17,6 @@ use Silex\Provider\TranslationServiceProvider;
use Silex\Provider\ValidatorServiceProvider; use Silex\Provider\ValidatorServiceProvider;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface;
use Symfony\Component\Form\FormTypeGuesserChain; use Symfony\Component\Form\FormTypeGuesserChain;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
...@@ -190,40 +189,24 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) { ...@@ -190,40 +189,24 @@ if (method_exists('Symfony\Component\Form\AbstractType', 'configureOptions')) {
} }
} }
if (!class_exists('Symfony\Component\Form\Extension\DataCollector\DataCollectorExtension')) { class FakeCsrfProvider implements CsrfTokenManagerInterface
// Symfony 2.3 only {
class FakeCsrfProvider implements CsrfProviderInterface public function getToken($tokenId)
{ {
public function generateCsrfToken($intention) return new CsrfToken($tokenId, '123');
{
return $intention.'123';
}
public function isCsrfTokenValid($intention, $token)
{
return $token === $this->generateCsrfToken($intention);
}
} }
} else {
class FakeCsrfProvider implements CsrfTokenManagerInterface
{
public function getToken($tokenId)
{
return new CsrfToken($tokenId, '123');
}
public function refreshToken($tokenId) public function refreshToken($tokenId)
{ {
return new CsrfToken($tokenId, '123'); return new CsrfToken($tokenId, '123');
} }
public function removeToken($tokenId) public function removeToken($tokenId)
{ {
} }
public function isTokenValid(CsrfToken $token) public function isTokenValid(CsrfToken $token)
{ {
return '123' === $token->getValue(); return '123' === $token->getValue();
}
} }
} }
...@@ -21,10 +21,6 @@ class HttpFragmentServiceProviderTest extends \PHPUnit_Framework_TestCase ...@@ -21,10 +21,6 @@ class HttpFragmentServiceProviderTest extends \PHPUnit_Framework_TestCase
{ {
public function testRenderFunction() public function testRenderFunction()
{ {
if (!class_exists('Symfony\Component\HttpFoundation\RequestStack')) {
$this->markTestSkipped('HttpFragmentServiceProvider is not available on Symfony <2.4');
}
$app = new Application(); $app = new Application();
$app->register(new HttpFragmentServiceProvider()); $app->register(new HttpFragmentServiceProvider());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment