-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Docs for referencing tagged services in config #8404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
da034d2
61c74da
71158f8
0aaf48b
000b801
a2fd23f
564b5ea
2e5c87f
ed70659
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -426,13 +426,13 @@ first constructor argument to the ``App\HandlerCollection`` service: | |
|
|
||
| # app/config/services.yml | ||
| services: | ||
| App\Handler\One: | ||
| AppBundle\Handler\One: | ||
| tags: [app.handler] | ||
|
|
||
| App\Handler\Two: | ||
| AppBundle\Handler\Two: | ||
| tags: [app.handler] | ||
|
|
||
| App\HandlerCollection: | ||
| AppBundle\HandlerCollection: | ||
| # inject all services tagged with app.handler as first argument | ||
| arguments: [!tagged app.handler] | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's put a comment here describing that this is passing all services tagged with |
||
|
|
||
|
|
@@ -446,15 +446,15 @@ first constructor argument to the ``App\HandlerCollection`` service: | |
| http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
|
||
| <services> | ||
| <service id="App\Handler\One"> | ||
| <service id="AppBundle\Handler\One"> | ||
| <tag name="app.handler" /> | ||
| </service> | ||
|
|
||
| <service id="App\Handler\Two"> | ||
| <service id="AppBundle\Handler\Two"> | ||
| <tag name="app.handler" /> | ||
| </service> | ||
|
|
||
| <service id="App\HandlerCollection"> | ||
| <service id="AppBundle\HandlerCollection"> | ||
| <!-- inject all services tagged with app.handler as first argument --> | ||
| <argument type="tagged" tag="app.handler" /> | ||
| </service> | ||
|
|
@@ -466,13 +466,13 @@ first constructor argument to the ``App\HandlerCollection`` service: | |
| // app/config/services.php | ||
| use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument; | ||
|
|
||
| $container->register(App\Handler\One::class) | ||
| $container->register(AppBundle\Handler\One::class) | ||
| ->addTag('app.handler'); | ||
|
|
||
| $container->register(App\Handler\Two::class) | ||
| $container->register(AppBundle\Handler\Two::class) | ||
| ->addTag('app.handler'); | ||
|
|
||
| $container->register(App\HandlerCollection::class) | ||
| $container->register(AppBundle\HandlerCollection::class) | ||
| // inject all services tagged with app.handler as first argument | ||
| ->addArgument(new TaggedIteratorArgument('app.handler')); | ||
|
|
||
|
|
@@ -481,6 +481,9 @@ application handlers. | |
|
|
||
| .. code-block:: php | ||
|
|
||
| // src/AppBundle/HandlerCollection.php | ||
| namespace AppBundle; | ||
|
|
||
| class HandlerCollection | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing namespace and filename comment |
||
| { | ||
| public function __construct(iterable $handlers) | ||
|
|
@@ -498,7 +501,7 @@ application handlers. | |
|
|
||
| # app/config/services.yml | ||
| services: | ||
| App\Handler\One: | ||
| AppBundle\Handler\One: | ||
| tags: | ||
| - { name: app.handler, priority: 20 } | ||
|
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line should be removed (versionadded is a really strange directive). And let's move this to just below the section title |
||
|
|
@@ -512,7 +515,7 @@ application handlers. | |
| http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
|
|
||
| <services> | ||
| <service id="App\Handler\One"> | ||
| <service id="AppBundle\Handler\One"> | ||
| <tag name="app.handler" priority="20" /> | ||
| </service> | ||
| </services> | ||
|
|
@@ -521,8 +524,7 @@ application handlers. | |
| .. code-block:: php | ||
|
|
||
| // app/config/services.php | ||
| $container->register(App\Handler\One::class) | ||
| $container->register(AppBundle\Handler\One::class) | ||
| ->addTag('app.handler', array('priority' => 20)); | ||
|
|
||
| Note that any other custom attributes will be ignored by this feature. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing filename comment (same for the other formats):
# app/config/services.yml