-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…rvice matching (codedmonkey) This PR was squashed before being merged into the 4.2-dev branch (closes #28571). Discussion ---------- [DependencyInjection] Improve ServiceLocatorTagPass service matching | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26892 | License | MIT | Doc PR | symfony/symfony-docs#10397 Allows omitting of keys for service locator arguments (it will automatically take over the original definition alias). Commits ------- 1c1210a3e8 [DependencyInjection] Improve ServiceLocatorTagPass service matching
…rvice matching (codedmonkey) This PR was squashed before being merged into the 4.2-dev branch (closes #28571). Discussion ---------- [DependencyInjection] Improve ServiceLocatorTagPass service matching | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #26892 | License | MIT | Doc PR | symfony/symfony-docs#10397 Allows omitting of keys for service locator arguments (it will automatically take over the original definition alias). Commits ------- 1c1210a [DependencyInjection] Improve ServiceLocatorTagPass service matching
Code has been merged :) |
@codedmonkey for this kind of features, we always add some comments and examples in the code samples, to make it easier to understand. Could you please my reword to do that? Thanks! |
@codedmonkey the current YAML example that I added is wrong: # config/services.yaml
services:
app.command_handler_locator:
class: Symfony\Component\DependencyInjection\ServiceLocator
arguments:
-
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' It says:
What's the correct syntax for YAML? Or maybe this feature is not supported in YAML? Thanks! |
Anyone knows if this feature works with YAML config? @xabbuh? @nicolas-grekas? If it works, which is the syntax? Thanks! |
My apologies for the late response. It looks like combining collections aand arrays in YAML is indeed a no-go, symfony/symfony#23664. It's possible to do either
or
but not a combination of the two. Trying to add the feature would just increase complexity. Any ideas how best to address this in the docs? |
That's correct, a collection in YAML is either a sequence or a mapping. I would just add a second example like this: # config/services.yaml
services:
app.command_handler_locator:
class: Symfony\Component\DependencyInjection\ServiceLocator
arguments:
-
App\FooCommand: '@app.command_handler.foo'
App\BarCommand: '@app.command_handler.bar'
# or if the element has no key, the ID of the original service is used
app.another_command_handler_locator:
class: Symfony\Component\DependencyInjection\ServiceLocator
arguments:
-
- '@app.command_handler.baz' |
@@ -314,6 +321,10 @@ include as many services as needed in it. | |||
previous Symfony versions you always needed to add the | |||
``container.service_locator`` tag explicitly. | |||
|
|||
.. versionadded:: 4.2 |
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.
Please add a blank line after the directive
a012eaf
to
8d8c65e
Compare
…tor changes (codedmonkey, javiereguiluz) This PR was submitted for the master branch but it was merged into the 4.3 branch instead (closes #10397). Discussion ---------- [DependencyInjection] Add documentation for service locator changes Adds documentation for PR symfony/symfony#28571 Commits ------- 8d8c65e Reword bc5ef85 [DependencyInjection] Add documentation for service locator changes
It took us forever ... but this is finally merged. Thank you all for your help and contributions. |
Adds documentation for PR symfony/symfony#28571