-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] allow decorating a lazy service using a final class if it's wired by an interface #53436
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
Shouldn't you split the extension from its runtime and all the troubles are fixed? |
@nicolas-grekas this is 3rd party code, not sure what steps you're suggesting here? 🤔 |
Submitting a PR to them? :) |
But what would the even PR do? 🤔 They did everything correctly AFAIK, it's Symfony lacking the "build step" which would cleanly separate building Twig templates (no env var access allowed) vs using Twig templates (env var access allowed), which we were discussing in #40794.
TIL, yes I am, thanks! 👍 I guess what I had in mind is already possible, maybe the PR to them could do that until Symfony fixes the build time vs runtime conundrum. |
buildtime vs runtime is what twig extension runtimes where created for, that lib should leverage them. |
Description
I'm implementing https://github.com/Unleash/unleash-client-symfony which has an interface used as the client and a default implementation which is final, all of which is good and correct.
The bundle also comes with Twig integration so you can use feature flag directly in Twig, again good stuff.
I'm using k8s and obviously want to manage the config via secrets, like so
Unfortunately, when pre-building the app with
cache:warmup
, this means the service is attempted to be created which fails (known issue):Reason is:
Typically, the solution is to make the client lazy since it will not actually be used, it's only needed to satisfy the dep enough to build the templates.
But here, since the client is final, I get
But, the Twig extension is actually not requesting that class, it's requesting by interface
Unleash\Client\Unleash
.Idea
The solution is to decorate the service with a non-final class. But, Symfony could do that too.
The idea here is to
Example
No response
The text was updated successfully, but these errors were encountered: