Permalink
Browse files

minor #4403 Improved naming (WouterJ)

This PR was merged into the 2.3 branch.

Discussion
----------

Improved naming

| Q   | A
| --- | ---
| Doc fix? | yes
| New docs? | no
| Applies to | all
| Fixed tickets | -

I always found this very confusing. Today, I decided to try to tackle it. It's hard to explain correctly using not that many words. I would like to hear other suggestions if you think those are better :)

Commits
-------

2665e1f Improved naming
  • Loading branch information...
wouterj committed Nov 18, 2014
2 parents 6298595 + 2665e1f commit 97d8f616f02e49daeb93dfc5719be312a3317292
Showing with 8 additions and 8 deletions.
  1. +8 −8 components/dependency_injection/tags.rst
@@ -153,7 +153,7 @@ custom tag::
$taggedServices = $container->findTaggedServiceIds(
'acme_mailer.transport'
);
foreach ($taggedServices as $id => $attributes) {
foreach ($taggedServices as $id => $tags) {
$definition->addMethodCall(
'addTransport',
array(new Reference($id))
@@ -178,7 +178,7 @@ run when the container is compiled::
use Symfony\Component\DependencyInjection\ContainerBuilder;
$container = new ContainerBuilder();
$container->addCompilerPass(new TransportCompilerPass);
$container->addCompilerPass(new TransportCompilerPass());
.. note::
@@ -291,8 +291,8 @@ use this, update the compiler::
$taggedServices = $container->findTaggedServiceIds(
'acme_mailer.transport'
);
foreach ($taggedServices as $id => $tagAttributes) {
foreach ($tagAttributes as $attributes) {
foreach ($taggedServices as $id => $tags) {
foreach ($tags as $attributes) {
$definition->addMethodCall(
'addTransport',
array(new Reference($id), $attributes["alias"])
@@ -302,7 +302,7 @@ use this, update the compiler::
}
}
The trickiest part is the ``$attributes`` variable. Because you can use the
same tag many times on the same service (e.g. you could theoretically tag
the same service 5 times with the ``acme_mailer.transport`` tag), ``$attributes``
is an array of the tag information for each tag on that service.
The double loop may be confusing. This is because a service can have more than one
tag. You tag a service twice or more with the ``acme_mailer.transport`` tag. The
second foreach loop iterates over the ``acme_mailer.transport`` tags set for the
current service and gives you the attributes.

0 comments on commit 97d8f61

Please sign in to comment.