8000 bug #5251 [Cookbook][Controller] replace docs for removed `forward()`… · ThomasLandauer/symfony-docs@f6db30e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit f6db30e

Browse files
committed
bug symfony#5251 [Cookbook][Controller] replace docs for removed forward() method (xabbuh)
This PR was merged into the 2.3 branch. Discussion ---------- [Cookbook][Controller] replace docs for removed `forward()` method | Q | A | ------------- | --- | Doc fix? | yes | New docs? | no | Applies to | all | Fixed tickets | symfony/symfony#8783 The `forward()` method was removed from the `HttpKernel` class in the FrameworkBundle in Symfony 2.3. Instead, the current request needs to be duplicated and handled by the kernel's `handle()` method. Commits ------- bd62078 replace docs for removed `forward()` method
2 parents ce7eb04 + bd62078 commit f6db30e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cookbook/controller/service.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,13 @@ controller:
258258
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::forward` (service: ``http_kernel``)
259259
.. code-block:: php
260260
261-
$httpKernel->forward($controller, $path, $query);
261+
use Symfony\Component\HttpKernel\HttpKernelInterface;
262+
// ...
263+
264+
$request = ...;
265+
$attributes = array_merge($path, array('_controller' => $controller));
266+
$subRequest = $request->duplicate($query, null, $attributes);
267+
$httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
262268
263269
:method:`Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller::generateUrl` (service: ``router``)
264270
.. code-block:: php

0 commit comments

Comments
 (0)
0