Closed wuestkamp closed 8 years ago
@kimwue Symfony makes absolutely no guarantee about when a particular service will get instantiated compared to calls to another service, as this depends on the whole object graph of dependencies between services. For your case, this is because there is now a cache warmer in TwigBundle warming up the Twig template, and so Twig needs to be instantiated when getting cache warmers.
This is why it is not recommended to put logic in the constructor (this is a general recommendation when using dependency injection, to avoid making heavy computation just because some other class asked for its dependency). Giving you more idea about how to refactor the logic to account for it is not possible with the amount of info available here, as I don't know what these classes are doing.
Thanks, that clears things up. We'll adjust our logic based on your info. Thanks for fast and great support!
Hi there,
we updated our application from 2.3 to 2.8. All went kind of well except one error. We have a custom
CmsWarmer
extendingCacheWarmer
.It seems that since 2.8 the
CmsWarmer->warmUp
gets called after the constructor of a customTwig_Extension
. This breaks because ourTwig_Extension
relies on file generated duringCmsWarmer->warmUp
.Setting priority with _kernel.cachewarmer does make the
CmsWarmer->__construct
to be executed before theTwig_Extension->__construct
, but theCmsWarmer->warmUp
still gets called at the very end.Any documentation on that or idea how to solve?
Thanks, Kim