Skip to content

Commit 277bc36

Browse files
committed
minor #9746 Add service binding to argument name example (kbond)
This PR was submitted for the master branch but it was merged into the 4.0 branch instead (closes #9746). Discussion ---------- Add service binding to argument name example I just learned this is possible - thought it should be documented. Commits ------- 6b1f9c1 add service binding to argument name example
2 parents 8ba6ec2 + 6b1f9c1 commit 277bc36

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

service_container.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type
639639
# that's defined in this file (including controller arguments)
640640
$adminEmail: 'manager@example.com'
641641
642+
# pass this service to any $requestLogger argument for any
643+
# service that's defined in this file
644+
$requestLogger: '@monolog.logger.request'
645+
642646
# pass this service for any LoggerInterface type-hint for any
643647
# service that's defined in this file
644648
Psr\Log\LoggerInterface: '@monolog.logger.request'
@@ -657,7 +661,11 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type
657661
<services>
658662
<defaults autowire="true" autoconfigure="true" public="false">
659663
<bind key="$adminEmail">manager@example.com</bind>
660-
<bind key="$logger"
664+
<bind key="$requestLogger"
665+
type="service"
666+
id="monolog.logger.request"
667+
/>
668+
<bind key="Psr\Log\LoggerInterface"
661669
type="service"
662670
id="monolog.logger.request"
663671
/>
@@ -678,6 +686,7 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type
678686
->setPublic(true)
679687
->setBindings(array(
680688
'$adminEmail' => 'manager@example.com',
689+
'$requestLogger' => new Reference('monolog.logger.request'),
681690
LoggerInterface::class => new Reference('monolog.logger.request'),
682691
))
683692
;

0 commit comments

Comments
 (0)