8000 feature #8558 Adding warning about non-service arguments for controll… · symfony/symfony-docs@656980b · GitHub
[go: up one dir, main page]

Skip to content

Commit 656980b

Browse files
committed
feature #8558 Adding warning about non-service arguments for controllers (weaverryan)
This PR was merged into the 3.3 branch. Discussion ---------- Adding warning about non-service arguments for controllers Hi guys! See: symfony/symfony#24555 (comment) This is for 3.3. In 3.4 we can improve this further: by updating the example of this to use `bind` (which is much nicer than the ugly tag) and probably show an example of using `bind` along with a scalar argument to the constructor. In other words, 3.4 is a todo once this is merged. Thanks! Commits ------- 72a0685 Adding warning about non-service arguments
2 parents 297da16 + 72a0685 commit 656980b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

controller.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,13 @@ controller's service config:
338338
You can of course also use normal :ref:`constructor injection <services-constructor-injection>`
339339
in your controllers.
340340

341+
.. caution::
342+
343+
You can *only* pass *services* to your controller arguments in this way. It's
344+
not possible, for example, to pass a service parameter as a controller argument.
345+
If you need a parameter, use the ``$this->getParameter('kernel.debug')`` shortcut
346+
or pass the value through your controller's ``__construct()`` method.
347+
341348
For more information about services, see the :doc:`/service_container` article.
342349

343350
.. _controller-service-arguments-tag:

0 commit comments

Comments
 (0)
0