-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Support anonymous services in Yaml #21970
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
5ba0c74
to
bec639f
Compare
c4f6dea
to
7a00fdb
Compare
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.
👍
Defaults and instanceof conditionals aren't applied on anonymous services, as in xml too.
Just wondering about this catch. Does anyone have an opinion on this? (for another PR thought)
|
||
throw new InvalidArgumentException(sprintf('Unsupported tag "!%s".', $value->getTag())); | ||
} | ||
|
||
if (is_array($value)) { | ||
$value = array_map(array($this, 'resolveServices'), $value); | ||
foreach ($value as &$v) { |
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.
would be better to get rid of the reference to me
@@ -696,12 +701,39 @@ private function resolveServices($value) | |||
|
|||
return new ClosureProxyArgument($argument[0], $argument[1], $invalidBehavior); | |||
} | |||
// Anonymous service |
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.
not sure this comment provides anything
Thinking a bit more about this, my opinion on it is that it's a bug that should be fixed in XmlFileLoader also. |
good to merge as is to me, my previous comments are for another PR |
Thank you @GuilhemN. |
…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
This PR allows creating anonymous services in yaml using the
!service
tag as proposed by @nicolas-grekas:Anonymous services are forbidden in parameters as in xml.
Defaults and instanceof conditionals aren't applied on anonymous services, as in xml too.