8000 replace docs for removed `forward()` method · symfony/symfony-docs@bd62078 · GitHub
[go: up one dir, main page]

Skip to content

Commit bd62078

Browse files
committed
replace docs for removed forward() method
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.
1 parent 3ebe1b2 commit bd62078

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