[DependencyInjection] Accessing processed extension configs #48408
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This proposal adds a new container parameter
.extension.processed_configs
that holds all processed extension configs from all registered extensions in order to improve the DX during the DI compilation phase (load extension, compiler pass).Before
Currently, it's not possible to access processed configs, so this new parameter will avoid unsafely and hacking workarounds just to query a config value that belongs to another (already processed) extension and derives some DI definitions from it.
Some workarounds involve:
processConfiguration()
method from another extension is forbidden as it's protected and final, meaning you'll have to process twice this config outside the extension owner.After
With this proposal, you'll access these configs through the
.extension.processed_configs
parameter. It's an array of extensions configs, where the array key matches the extension alias:Note that in
load
orloadExtension
you have access only to already loaded extensions depending on the extension/bundle definition order. If you need access to other extension configs that are not loaded yet then move your logic to a compiler pass or change the bundle/extension order in thebundle.php
file of your project.Also available in any compiler pass with the capability to resolve env placeholders:
After merging #47680 this
.extension.processed_configs
parameter is considered a "build parameter" finally, so it will be used during compiler time only and will be removed at the end of the process.