Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
c90fa7f to4f282e8Compare4f282e8 to455375fCompareSongoQ commentedOct 24, 2015
👍 |
sstok commentedOct 24, 2015
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. |
prgTW commentedOct 24, 2015
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 |
linaori commentedOct 24, 2015
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. |
stof commentedOct 25, 2015
-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) |
xabbuh commentedOct 25, 2015
Status: Needs work |
fabpot commentedOct 25, 2015
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. |
GuilhemN commentedMar 11, 2017
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:```ymlservices: _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: