File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,22 @@ Invokable Controllers
80
80
81
81
If your controller implements the ``__invoke() `` method - popular with the
82
82
Action-Domain-Response (ADR) pattern, you can simply refer to the service id
83
- (``AppBundle\Controller\HelloController `` or ``app.hello_controller `` for example).
83
+ (e.g. ``AppBundle\Controller\HelloController `` or ``app.hello_controller ``)::
84
+
85
+ // src/AppBundle/Controller/Hello.php
86
+ use Symfony\Component\HttpFoundation\Response;
87
+ use Symfony\Component\Routing\Annotation\Route;
88
+
89
+ /**
90
+ * @Route("/hello/{name}", name="hello", service="AppBundle\Controller\Hello")
91
+ */
92
+ class Hello
93
+ {
94
+ public function __invoke($name = 'World')
95
+ {
96
+ return new Response(sprintf('Hello %s!', $name));
97
+ }
98
+ }
84
99
85
100
Alternatives to base Controller Methods
86
101
---------------------------------------
You can’t perform that action at this time.
0 commit comments