Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[DependencyInjection] Add documentation for service locator changes#10397
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
27 changes: 22 additions & 5 deletionsservice_container/service_subscribers_locators.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -243,8 +243,8 @@ Defining a Service Locator | ||
| -------------------------- | ||
| To manually define a service locator, create a new service definition and add | ||
| the ``container.service_locator`` tag to it. Usethe first argument of the | ||
| service definition to pass a collection ofservicesto the service locator: | ||
| .. configuration-block:: | ||
| @@ -258,6 +258,9 @@ include as many services as needed in it. | ||
| - | ||
| App\FooCommand: '@app.command_handler.foo' | ||
| App\BarCommand: '@app.command_handler.bar' | ||
| # if the element has no key, the ID of the original service is used | ||
| '@app.command_handler.baz' | ||
| # if you are not using the default service autoconfiguration, | ||
| # add the following tag to the service definition: | ||
| # tags: ['container.service_locator'] | ||
| @@ -274,8 +277,10 @@ include as many services as needed in it. | ||
| <service id="app.command_handler_locator" class="Symfony\Component\DependencyInjection\ServiceLocator"> | ||
| <argument type="collection"> | ||
| <argument key="App\FooCommand" type="service" id="app.command_handler.foo" /> | ||
| <argument key="App\BarCommand" type="service" id="app.command_handler.bar" /> | ||
| <!-- if the element has no key, the ID of the original service is used --> | ||
| <argument type="service" id="app.command_handler.baz" /> | ||
| </argument> | ||
| <!-- | ||
| if you are not using the default service autoconfiguration, | ||
| @@ -300,12 +305,24 @@ include as many services as needed in it. | ||
| ->setArguments([[ | ||
| 'App\FooCommand' => new Reference('app.command_handler.foo'), | ||
| 'App\BarCommand' => new Reference('app.command_handler.bar'), | ||
| // if the element has no key, the ID of the original service is used | ||
| new Reference('app.command_handler.baz'), | ||
| ))) | ||
| // if you are not using the default service autoconfiguration, | ||
| // add the following tag to the service definition: | ||
| // ->addTag('container.service_locator') | ||
| ; | ||
| .. versionadded:: 4.1 | ||
| The service locator autoconfiguration was introduced in Symfony 4.1. In | ||
| previous Symfony versions you always needed to add the | ||
| ``container.service_locator`` tag explicitly. | ||
| .. versionadded:: 4.2 | ||
Contributor 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. Please add a blank line after the directive | ||
| The ability to add services without specifying their id was introduced in | ||
| Symfony 4.2. | ||
| .. note:: | ||
| The services defined in the service locator argument must include keys, | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.