Skip to content

Commit ae7c378

Browse files
committed
[Form] Renamed form processors to request handlers
1 parent 51a3561 commit ae7c378

19 files changed

+102
-98
lines changed

UPGRADE-3.0.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ UPGRADE FROM 2.x to 3.0
2222

2323
* Passing a `Symfony\Component\HttpFoundation\Request` instance to
2424
`FormInterface::bind()` was disabled. You should use
25-
`FormInterface::process()` instead.
25+
`FormInterface::handleRequest()` instead.
2626

2727
Before:
2828

@@ -39,7 +39,9 @@ UPGRADE FROM 2.x to 3.0
3939
After:
4040

4141
```
42-
if ($form->process($request)->isValid()) {
42+
$form->handleRequest();
43+
44+
if ($form->isValid()) {
4345
// ...
4446
}
4547
```
@@ -48,7 +50,9 @@ UPGRADE FROM 2.x to 3.0
4850
the method `isBound()`:
4951

5052
```
51-
if ($form->process($request)->isBound()) {
53+
$form->handleRequest();
54+
55+
if ($form->isBound()) {
5256
// ...
5357
5458
if ($form->isValid()) {

src/Symfony/Component/Form/Button.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ public function isSynchronized()
350350
*
351351
* @throws BadMethodCallException
352352
*/
353-
public function process($request = null)
353+
public function handleRequest($request = null)
354354
{
355355
throw new BadMethodCallException('Buttons cannot be processed. Call process() on the root form instead.');
356356
}

src/Symfony/Component/Form/ButtonBuilder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,11 @@ public function setMethod($method)
483483
/**
484484
* Unsupported method.
485485
*
486-
* @param FormProcessorInterface $formProcessor
486+
* @param RequestHandlerInterface $requestHandler
487487
*
488488
* @throws BadMethodCallException
489489
*/
490-
public function setFormProcessor(FormProcessorInterface $formProcessor)
490+
public function setRequestHandler(RequestHandlerInterface $requestHandler)
491491
{
492492
throw new BadMethodCallException('Buttons do not support form processors.');
493493
}
@@ -766,7 +766,7 @@ public function getMethod()
766766
*
767767
* @return null Always returns null.
768768
*/
769-
public function getFormProcessor()
769+
public function getRequestHandler()
770770
{
771771
return null;
772772
}

src/Symfony/Component/Form/CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CHANGELOG
88
* deprecated FormPerformanceTestCase and FormIntegrationTestCase in the Symfony\Component\Form\Tests namespace and moved them to the Symfony\Component\Form\Test namespace
99
* deprecated TypeTestCase in the Symfony\Component\Form\Tests\Extension\Core\Type namespace and moved it to the Symfony\Component\Form\Test namespace
1010
* changed FormRenderer::humanize() to humanize also camel cased field name
11-
* added FormProcessorInterface and FormInterface::process()
11+
* added RequestHandlerInterface and FormInterface::handleRequest()
1212
* deprecated passing a Request instance to FormInterface::bind()
1313
* added options "method" and "action" to FormType
1414
* deprecated option "virtual" in favor "inherit_data"

src/Symfony/Component/Form/Extension/HttpFoundation/RequestFormProcessor.php renamed to src/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
use Symfony\Component\Form\Exception\InvalidArgumentException;
1515
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1616
use Symfony\Component\Form\FormInterface;
17-
use Symfony\Component\Form\FormProcessorInterface;
17+
use Symfony\Component\Form\RequestHandlerInterface;
1818
use Symfony\Component\HttpFoundation\Request;
1919

2020
/**
21-
* A form processor using the {@link Request} class of the HttpFoundation
21+
* A request processor using the {@link Request} class of the HttpFoundation
2222
* component.
2323
*
2424
* @author Bernhard Schussek <bschussek@gmail.com>
2525
*/
26-
class RequestFormProcessor implements FormProcessorInterface
26+
class HttpFoundationRequestHandler implements RequestHandlerInterface
2727
{
2828
/**
2929
* {@inheritdoc}
3030
*/
31-
public function processForm(FormInterface $form, $request = null)
31+
public function handleRequest(FormInterface $form, $request = null)
3232
{
3333
if (!$request instanceof Request) {
3434
throw new UnexpectedTypeException($request, 'Symfony\Component\HttpFoundation\Request');

src/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Symfony\Component\Form\AbstractTypeExtension;
1515
use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener;
16-
use Symfony\Component\Form\Extension\HttpFoundation\RequestFormProcessor;
16+
use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler;
1717
use Symfony\Component\Form\FormBuilderInterface;
1818

1919
/**
@@ -27,14 +27,14 @@ class FormTypeHttpFoundationExtension extends AbstractTypeExtension
2727
private $listener;
2828

2929
/**
30-
* @var RequestFormProcessor
30+
* @var HttpFoundationRequestHandler
3131
*/
32-
private $processor;
32+
private $requestHandler;
3333

3434
public function __construct()
3535
{
3636
$this->listener = new BindRequestListener();
37-
$this->processor = new RequestFormProcessor();
37+
$this->requestHandler = new HttpFoundationRequestHandler();
3838
}
3939

4040
/**
@@ -43,7 +43,7 @@ public function __construct()
4343
public function buildForm(FormBuilderInterface $builder, array $options)
4444
{
4545
$builder->addEventSubscriber($this->listener);
46-
$builder->setFormProcessor($this->processor);
46+
$builder->setRequestHandler($this->requestHandler);
4747
}
4848

4949
/**

src/Symfony/Component/Form/Form.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -454,9 +454,9 @@ public function getExtraData()
454454
/**
455455
* {@inheritdoc}
456456
*/
457-
public function process($request = null)
457+
public function handleRequest($request = null)
458458
{
459-
$this->config->getFormProcessor()->processForm($this, $request);
459+
$this->config->getRequestHandler()->handleRequest($this, $request);
460460

461461
return $this;
462462
}

src/Symfony/Component/Form/FormConfigBuilder.php

+13-13
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@
2828
class FormConfigBuilder implements FormConfigBuilderInterface
2929
{
3030
/**
31-
* Caches a globally unique {@link NativeFormProcessor} instance.
31+
* Caches a globally unique {@link NativeRequestHandler} instance.
3232
*
33-
* @var NativeFormProcessor
33+
* @var NativeRequestHandler
3434
*/
35-
private static $nativeFormProcessor;
35+
private static $nativeRequestProcessor;
3636

3737
/**
3838
* The accepted request methods.
@@ -168,9 +168,9 @@ class FormConfigBuilder implements FormConfigBuilderInterface
168168
private $method = 'POST';
169169

170170
/**
171-
* @var FormProcessorInterface
171+
* @var RequestHandlerInterface
172172
*/
173-
private $formProcessor;
173+
private $requestHandler;
174174

175175
/**
176176
* @var array
@@ -509,16 +509,16 @@ public function getMethod()
509509
/**
510510
* {@inheritdoc}
511511
*/
512-
public function getFormProcessor()
512+
public function getRequestHandler()
513513
{
514-
if (null === $this->formProcessor) {
515-
if (null === self::$nativeFormProcessor) {
516-
self::$nativeFormProcessor = new NativeFormProcessor();
514+
if (null === $this->requestHandler) {
515+
if (null === self::$nativeRequestProcessor) {
516+
self::$nativeRequestProcessor = new NativeRequestHandler();
517517
}
518-
$this->formProcessor = self::$nativeFormProcessor;
518+
$this->requestHandler = self::$nativeRequestProcessor;
519519
}
520520

521-
return $this->formProcessor;
521+
return $this->requestHandler;
522522
}
523523

524524
/**
@@ -832,13 +832,13 @@ public function setMethod($method)
832832
/**
833833
* {@inheritdoc}
834834
*/
835-
public function setFormProcessor(FormProcessorInterface $formProcessor)
835+
public function setRequestHandler(RequestHandlerInterface $requestHandler)
836836
{
837837
if ($this->locked) {
838838
throw new BadMethodCallException('The config builder cannot be modified anymore.');
839839
}
840840

841-
$this->formProcessor = $formProcessor;
841+
$this->requestHandler = $requestHandler;
842842

843843
return $this;
844844
}

src/Symfony/Component/Form/FormConfigBuilderInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,11 +256,11 @@ public function setAction($action);
256256
public function setMethod($method);
257257

258258
/**
259-
* @param FormProcessorInterface $formProcessor
259+
* @param RequestHandlerInterface $requestHandler
260260
*
261261
* @return self The configuration object.
262262
*/
263-
public function setFormProcessor(FormProcessorInterface $formProcessor);
263+
public function setRequestHandler(RequestHandlerInterface $requestHandler);
264264

265265
/**
266266
* Builds and returns the form configuration.

src/Symfony/Component/Form/FormConfigInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ public function getAction();
201201
public function getMethod();
202202

203203
/**
204-
* @return FormProcessorInterface The form processor.
204+
* @return RequestHandlerInterface The form processor.
205205
*/
206-
public function getFormProcessor();
206+
public function getRequestHandler();
207207

208208
/**
209209
* Returns all options passed during the construction of the form.

src/Symfony/Component/Form/FormInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -229,15 +229,15 @@ public function isSynchronized();
229229
/**
230230
* Processes the given request and binds the form if it was submitted.
231231
*
232-
* Internally, the request is forwarded to a {@link FormProcessorInterface}
232+
* Internally, the request is forwarded to a {@link RequestHandlerInterface}
233233
* instance. This instance determines the allowed value of the
234234
* $request parameter.
235235
*
236236
* @param mixed $request The request to check.
237237
*
238238
* @return FormInterface The form instance.
239239
*/
240-
public function process($request = null);
240+
public function handleRequest($request = null);
241241

242242
/**
243243
* Binds data to the form, transforms and validates it.

src/Symfony/Component/Form/NativeFormProcessor.php renamed to src/Symfony/Component/Form/NativeRequestHandler.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313

1414
use Symfony\Component\Form\Exception\UnexpectedTypeException;
1515
use Symfony\Component\Form\FormInterface;
16-
use Symfony\Component\Form\FormProcessorInterface;
16+
use Symfony\Component\Form\RequestHandlerInterface;
1717

1818
/**
19-
* A form processor using PHP's super globals $_GET, $_POST and $_SERVER.
19+
* A request handler using PHP's super globals $_GET, $_POST and $_SERVER.
2020
*
2121
* @author Bernhard Schussek <bschussek@gmail.com>
2222
*/
23-
class NativeFormProcessor implements FormProcessorInterface
23+
class NativeRequestHandler implements RequestHandlerInterface
2424
{
2525
/**
2626
* The allowed keys of the $_FILES array.
@@ -38,7 +38,7 @@ class NativeFormProcessor implements FormProcessorInterface
3838
/**
3939
* {@inheritdoc}
4040
*/
41-
public function processForm(FormInterface $form, $request = null)
41+
public function handleRequest(FormInterface $form, $request = null)
4242
{
4343
if (null !== $request) {
4444
throw new UnexpectedTypeException($request, 'null');

src/Symfony/Component/Form/FormProcessorInterface.php renamed to src/Symfony/Component/Form/RequestHandlerInterface.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@
1616
*
1717
* @author Bernhard Schussek <bschussek@gmail.com>
1818
*/
19-
interface FormProcessorInterface
19+
interface RequestHandlerInterface
2020
{
2121
/**
2222
* Binds a form from a request if it was submitted.
2323
*
2424
* @param FormInterface $form The form to bind.
2525
* @param mixed $request The current request.
2626
*/
27-
public function processForm(FormInterface $form, $request = null);
27+
public function handleRequest(FormInterface $form, $request = null);
2828
}

0 commit comments

Comments
 (0)