-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Create a new trait or class to resolve values with the container #17160
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
Comments
Generally, this should be possible. We would need something like a |
I created a new |
…ess parameters as-a-service (nicolas-grekas, sroze) This PR was merged into the 4.1-dev branch. Discussion ---------- [DI][FrameworkBundle] Add PSR-11 "ContainerBag" to access parameters as-a-service | Q | A | ------------- | --- | Branch? | master | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17160 | License | MIT | Doc PR | - There is one thing that prevents us from not injecting the container: access to the parameter bag. This PR fixes this limitation by providing a PSR-11 `ContainerBagInterface` + related implementation, and wiring it as a service that ppl can then also autowire using the new interface as a type hint, or `ParameterBagInterface`. Needed to complete e.g. #24738 Commits ------- 561cd7e Add tests on the ContainerBag 0e18d3e [DI][FrameworkBundle] Add PSR-11 "ContainerBag" to access parameters as-a-service
Closing as fixed by #25288. |
Actually, to resolve a value we can use
ParameterBag::resolveValue()
which is accessible in theContainer
.This works fine but the problem is when we want to resolve a value at runtime and we have a custom
ContainerInterface
instance.So I would like to have a trait or a class which would allow to resolve values without an access to a
ParameterBag
instance.You can find an example of use case in
FOSRestBundle
where we need to resolve values at runtime.We actually use a trait but I'd prefer to use something from the core.
The text was updated successfully, but these errors were encountered: