File tree 1 file changed +4
-8
lines changed
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:
241
241
bind :
242
242
# for any $logger argument, pass this specific service
243
243
$logger : ' @monolog.logger.doctrine'
244
+ # for any $projectDir argument, pass this parameter value
245
+ $projectDir : ' %kernel.project_dir%'
244
246
245
247
.. code-block :: xml
246
248
@@ -260,6 +262,7 @@ the argument by its name:
260
262
type =" service"
261
263
id =" monolog.logger.doctrine"
262
264
/>
265
+ <bind key =" $projectDir" >%kernel.project_dir%</bind >
263
266
</service >
264
267
</services >
265
268
</container >
@@ -274,20 +277,13 @@ the argument by its name:
274
277
->setPublic(true)
275
278
->setBindings(array(
276
279
'$logger' => new Reference('monolog.logger.doctrine'),
280
+ '$projectDir' => '%kernel.project_dir%'
277
281
))
278
282
;
279
283
280
284
You can of course also use normal :ref: `constructor injection <services-constructor-injection >`
281
285
in your controllers.
282
286
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
-
291
287
For more information about services, see the :doc: `/service_container ` article.
292
288
293
289
.. index ::
You can’t perform that action at this time.
0 commit comments