File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,9 @@ and calls the defined controller. The ``forward()`` method returns the
1111:class: `Symfony\\ Component\\ HttpFoundation\\ Response ` object that is returned
1212from *that * controller::
1313
14- public function index (string $name): Response
14+ public function __invoke (string $name): Response
1515 {
16- $response = $this->forward('App\Controller\ OtherController::fancy ', [
16+ $response = $this->forward('OtherController::class ', [
1717 'name' => $name,
1818 'color' => 'green',
1919 ]);
@@ -26,10 +26,16 @@ from *that* controller::
2626The array passed to the method becomes the arguments for the resulting controller.
2727The target controller method might look something like this::
2828
29- public function fancy (string $name, string $color): Response
29+ public function __invoke (string $name, string $color): Response
3030 {
3131 // ... create and return a Response object
3232 }
3333
3434Like when creating a controller for a route, the order of the arguments of the
35- ``fancy() `` method doesn't matter: the matching is done by name.
35+ target method doesn't matter: the matching is done by name.
36+
37+ .. note ::
38+
39+ Twig's ``app.current_route `` will be empty after such a ``->forward() ``.
40+ But you can set its value manually by adding an array key ``_route `` to
41+ `forward()```s second argument.
You can’t perform that action at this time.
0 commit comments