@@ -153,7 +153,7 @@ custom tag::
153
153
$taggedServices = $container->findTaggedServiceIds(
154
154
'acme_mailer.transport'
155
155
);
156
- foreach ($taggedServices as $id => $attributes ) {
156
+ foreach ($taggedServices as $id => $tags ) {
157
157
$definition->addMethodCall(
158
158
'addTransport',
159
159
array(new Reference($id))
@@ -178,7 +178,7 @@ run when the container is compiled::
178
178
use Symfony\Component\DependencyInjection\ContainerBuilder;
179
179
180
180
$container = new ContainerBuilder();
181
- $container->addCompilerPass(new TransportCompilerPass);
181
+ $container->addCompilerPass(new TransportCompilerPass() );
182
182
183
183
.. note ::
184
184
@@ -291,8 +291,8 @@ use this, update the compiler::
291
291
$taggedServices = $container->findTaggedServiceIds(
292
292
'acme_mailer.transport'
293
293
);
294
- foreach ($taggedServices as $id => $tagAttributes ) {
295
- foreach ($tagAttributes as $attributes) {
294
+ foreach ($taggedServices as $id => $tags ) {
295
+ foreach ($tags as $attributes) {
296
296
$definition->addMethodCall(
297
297
'addTransport',
298
298
array(new Reference($id), $attributes["alias"])
@@ -302,7 +302,7 @@ use this, update the compiler::
302
302
}
303
303
}
304
304
305
- The trickiest part is the `` $attributes `` variable. Because you can use the
306
- same tag many times on the same service (e.g. you could theoretically tag
307
- the same service 5 times with the ``acme_mailer.transport `` tag), `` $attributes ``
308
- is an array of the tag information for each tag on that service .
305
+ The double loop may be confusing. This is because a service can have more than one
306
+ tag. You tag a service twice or more with the `` acme_mailer.transport `` tag. The
307
+ second foreach loop iterates over the ``acme_mailer.transport `` tags set for the
308
+ current service and gives you the attributes .
0 commit comments