File tree Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Expand file tree Collapse file tree 1 file changed +4
-8
lines changed Original file line number Diff line number Diff line change @@ -241,6 +241,8 @@ the argument by its name:
241241 bind :
242242 # for any $logger argument, pass this specific service
243243 $logger : ' @monolog.logger.doctrine'
244+ # for any $projectDir argument, pass this parameter value
245+ $projectDir : ' %kernel.project_dir%'
244246
245247 .. code-block :: xml
246248
@@ -260,6 +262,7 @@ the argument by its name:
260262 type =" service"
261263 id =" monolog.logger.doctrine"
262264 />
265+ <bind key =" $projectDir" >%kernel.project_dir%</bind >
263266 </service >
264267 </services >
265268 </container >
@@ -274,20 +277,13 @@ the argument by its name:
274277 ->setPublic(true)
275278 ->setBindings(array(
276279 '$logger' => new Reference('monolog.logger.doctrine'),
280+ '$projectDir' => '%kernel.project_dir%'
277281 ))
278282 ;
279283
280284 You can of course also use normal :ref: `constructor injection <services-constructor-injection >`
281285in your controllers.
282286
283- .. caution ::
284-
285- You can *only * pass *services * to your controller arguments in this way. It's not
286- possible, for example, to pass a service parameter as a controller argument,
287- even by using ``bind ``. If you need a parameter, use the ``$this->getParameter('kernel.debug') ``
288- shortcut or pass the value through your controller's ``__construct() `` method
289- and specify its value with ``bind ``.
290-
291287For more information about services, see the :doc: `/service_container ` article.
292288
293289.. index ::
You can’t perform that action at this time.
0 commit comments