From 431251835ce63c492367595a0e49f4ff72104e4d Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Fri, 23 Mar 2018 12:02:08 -0400 Subject: [PATCH 1/2] Removing warning about bind + controller + scalar values --- controller.rst | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/controller.rst b/controller.rst index 69c609ee167..3977f7a67d4 100644 --- a/controller.rst +++ b/controller.rst @@ -241,6 +241,8 @@ the argument by its name: bind: # for any $logger argument, pass this specific service $logger: '@monolog.logger.doctrine' + # for any $projectDir argument, pass this parameter value + $projectDir: '%kernel.project_dir%' .. code-block:: xml @@ -260,6 +262,7 @@ the argument by its name: type="service" id="monolog.logger.doctrine" /> + %kernel.project_dir% @@ -274,20 +277,13 @@ the argument by its name: ->setPublic(true) ->setBindings(array( '$logger' => new Reference('monolog.logger.doctrine'), + '$projectDir' => '%kernel.project_dir%' )) ; You can of course also use normal :ref:`constructor injection ` in your controllers. -.. caution:: - - You can *only* pass *services* to your controller arguments in this way. It's not - possible, for example, to pass a service parameter as a controller argument, - even by using ``bind``. If you need a parameter, use the ``$this->getParameter('kernel.debug')`` - shortcut or pass the value through your controller's ``__construct()`` method - and specify its value with ``bind``. - For more information about services, see the :doc:`/service_container` article. .. index:: From af00dbc796d79d70335ec4da720702a2f54bc4b4 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Fri, 23 Mar 2018 12:39:37 -0400 Subject: [PATCH 2/2] adding version note about scalar bind args --- controller.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controller.rst b/controller.rst index 3977f7a67d4..f5116e023e5 100644 --- a/controller.rst +++ b/controller.rst @@ -284,6 +284,10 @@ the argument by its name: You can of course also use normal :ref:`constructor injection ` in your controllers. +.. versionadded:: 4.1 + The ability to bind scalar values to controller arguments was introduced in + Symfony 4.1. Previously you could only bind services. + For more information about services, see the :doc:`/service_container` article. .. index:: pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy