-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DI] Anonymous services support for YamlFileLoader #16328
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
c90fa7f
to
4f282e8
Compare
4f282e8
to
455375f
Compare
👍 |
This is a BC break as an argument can also an array, and there is no way to determine if it is in fact an array with the key 'type' or a service definition. |
You re right, it's a BC break. IMHO I'm introducing a convention here which is similar to @/@@/@?/@= notation. I wanted to do it as similar as it could be comparing with XML format and thus having steep learning curve |
I can understand the need for this, but I don't think this current implementation is the correct one. Can you add some more information about what you're changing and why you're changing it? It will help people to understand the PR a lot better. |
-1 on the current implementation. Such BC break is impossible. It is far too big (imagine the case where you inject an array in your service without knowing its content as it comes from the user config) |
Status: Needs work |
Closing as it cannot be merged and I don't see a huge benefit in being able to create anonymous services in userland. For core and bundles, it's recommended to use XML anyway where anonymous services are supported. |
I opened #21970 which allows anonymous services in yaml using the |
…ml (GuilhemN) This PR was merged into the 3.3-dev branch. Discussion ---------- [DependencyInjection] Support anonymous services in Yaml | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes <!-- don't forget updating src/**/CHANGELOG.md files --> | BC breaks? | no | Deprecations? | no <!-- don't forget updating UPGRADE-*.md files --> | Tests pass? | yes | Fixed tickets | #16328 | License | MIT | Doc PR | This PR allows creating anonymous services in yaml using the `!service` tag as proposed by @nicolas-grekas: ```yml services: _instanceof: FooInterface: arguments: - !service class: Bar autowire: true Foo: factory: [ !service { class: Quz }, 'constructFoo' ] ``` Anonymous services are forbidden in parameters as in xml. Defaults and instanceof conditionals aren't applied on anonymous services, as in xml too. Commits ------- 9b71385 [DependencyInjection] Support anonymous services in Yaml
Example: