From 27d228c3ee9e5615dc5393ecd21d62bddcb5083e Mon Sep 17 00:00:00 2001 From: Alessandro Chitolina Date: Tue, 28 Aug 2018 14:20:46 +0200 Subject: [PATCH] [Form] remove restriction on allowed http methods --- .../FrameworkBundle/Resources/config/form.xml | 1 - src/Symfony/Component/Form/CHANGELOG.md | 1 + .../Component/Form/FormConfigBuilder.php | 21 +------------------ .../Component/Form/Tests/FormConfigTest.php | 8 ------- 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml index 504fe619bf4d4..4f86ebb322ba4 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml @@ -29,7 +29,6 @@ - diff --git a/src/Symfony/Component/Form/CHANGELOG.md b/src/Symfony/Component/Form/CHANGELOG.md index 388d11652994f..7b8cf5093cbdd 100644 --- a/src/Symfony/Component/Form/CHANGELOG.md +++ b/src/Symfony/Component/Form/CHANGELOG.md @@ -9,6 +9,7 @@ CHANGELOG * deprecated calling `FormRenderer::searchAndRenderBlock` for fields which were already rendered * added a cause when a CSRF error has occurred * deprecated the `scale` option of the `IntegerType` + * removed restriction on allowed HTTP methods 4.1.0 ----- diff --git a/src/Symfony/Component/Form/FormConfigBuilder.php b/src/Symfony/Component/Form/FormConfigBuilder.php index fbed08beda00d..6a5a8d95b3f3a 100644 --- a/src/Symfony/Component/Form/FormConfigBuilder.php +++ b/src/Symfony/Component/Form/FormConfigBuilder.php @@ -34,19 +34,6 @@ class FormConfigBuilder implements FormConfigBuilderInterface */ private static $nativeRequestHandler; - /** - * The accepted request methods. - * - * @var array - */ - private static $allowedMethods = array( - 'GET', - 'PUT', - 'POST', - 'DELETE', - 'PATCH', - ); - /** * @var bool */ @@ -788,13 +775,7 @@ public function setMethod($method) throw new BadMethodCallException('The config builder cannot be modified anymore.'); } - $upperCaseMethod = strtoupper($method); - - if (!\in_array($upperCaseMethod, self::$allowedMethods)) { - throw new InvalidArgumentException(sprintf('The form method is "%s", but should be one of "%s".', $method, implode('", "', self::$allowedMethods))); - } - - $this->method = $upperCaseMethod; + $this->method = strtoupper($method); return $this; } diff --git a/src/Symfony/Component/Form/Tests/FormConfigTest.php b/src/Symfony/Component/Form/Tests/FormConfigTest.php index bb922bf3d61ff..0d21b83ab01fb 100644 --- a/src/Symfony/Component/Form/Tests/FormConfigTest.php +++ b/src/Symfony/Component/Form/Tests/FormConfigTest.php @@ -138,14 +138,6 @@ public function testSetMethodAllowsPatch() self::assertSame('PATCH', $formConfigBuilder->getMethod()); } - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testSetMethodDoesNotAllowOtherValues() - { - $this->getConfigBuilder()->setMethod('foo'); - } - private function getConfigBuilder($name = 'name') { $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();