-
-
Notifications
You must be signed in to change notification settings - Fork 455
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
Support using custom service via configuration for SLC factory #1814
Comments
Autowiring in bundles is discouraged. However, I think you were on the right track, it's just that it seems you are confused about service ids. Keys in your services.yaml file are service IDs, not class names. It just happens that some of the service IDs equal their class names, which is not the case here. Have you tried - App\Doctrine\CacheFactory:
doctrine.orm.default_second_level_cache.default_cache_factory:
class: App\Doctrine\CacheFactory:
autowire: true
autoconfigure: true ? |
Thank you for the quick answer! I have tried the suggestion above, and, while it works, it means that I have to define the factory based on this internal ID (which requires knowledge of how this bundle formats it in the first place). |
@ostrolucky Sorry about the confusion, it looks like your suggestion does not work either, actually. So:
Does not work on its own, it just uses the DefaultCacheFactory implementation instead of my own.
I get an error when generating the cache: So, it seems the only viable option is the kernel pass. |
|
Hello, would it be possible to enable autowiring/autoconfiguration when a custom factory is specified for the second level cache?
I attempted enabling autowiring/autoconfiguring for my custom factory in services.yaml, as such:
However this does not work, only the two arguments specified in the DoctrineExtension.php are passed.
My only solution to fix this was to enable them via a compiler pass:
I probably could get away by adding the service ID itself in my services.yaml and enabling autowiring/autoconfiguring that way, but it needs to be done for each factory ( the IDs the bundle generate are naturally different), which is very repetitive when you have multiple connections/ems/2nd level caches, which is why I am proposing this change in the bundle itself.
I believe this should be as simple as calling
->autowire(true)
and->autoconfigure(true)
, as shown above, in the DoctrineExtension.php:DoctrineBundle/src/DependencyInjection/DoctrineExtension.php
Lines 931 to 936 in 1ea2b5b
I can make this change, if you agree with it and do not see any downsides.
The text was updated successfully, but these errors were encountered: