-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Add custom container configurators #25650
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
[DependencyInjection] Add custom container configurators #25650
Conversation
unkind
commented
Jan 1, 2018
Q | A |
---|---|
Branch? | master |
Bug fix? | no |
New feature? | yes |
BC breaks? | no |
Deprecations? | no |
Tests pass? | let's see |
Fixed tickets | #25630 |
License | MIT |
Doc PR | - |
398cfdd
to
8d9d172
Compare
8d9d172
to
00e830f
Compare
Any chance to merge it in 4.1? It's a challenge to make it without changes in the core so far: |
What about something like $c->extension('my_ext', ['primitive' => 'config']);
// vs.
/** @var MyExtConfigurator $myExt */
$myExt = $c->extension('my_ext');
$myExt
->fluent('config'); Thus support both flavors, as well as multiple extension per-config. With a corresponding |
Or: $myExt = $c->extension('my_ext')->configure(function (MyExtConfigurator $myExt) {
return $myExt->foo('bar');
}); |
Or: $c->extension(function(MyExtConfigurator $e) {
$e->fluent('config');
}); Where's my cookie? :) |
I'm not convinced this is the approach we need in core. The idea I proposed in #25630 doesn't require any code at all, thus not any new concept/methods/api: return function (ContainerConfigurator $c) {
$myBundle = new MyBundleConfigurator($c);
$myBundle->setWhatever();
} To me, configuration is the correct place to do "new". Note that I'd also really like to be able to autocomplete bundle config using fluent configurator. |
Hmm, what's the difference? Closure or anonymous class? The issue is a bit deeper than it may look. Also, YAML/XML are cool when you need to generate them, e.g. you have some kind of "hexagons" (in terms of hexagonal architecture), they have different namespaces, you have to register it for auto wiring, etc., so config generation here is perfect solution. But when you deal with manual changes, I still don't see better solution than plain PHP. |