Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
[TwigBundle] Fixed caching of templates in src/Resources/<BundleName>/views on cache warmup #28376
This iterator suffers from tachycardia having to duplicate the paths registration and convention :)
Note that we're still missing custom paths registered in a third party bundles through
$container->getDefinition('twig.loader.native_filesystem') ->addMethodCall('addPath', array('/foo/templates/path', 'Foo'));
The templates inside it, will not be cached on cache warmup.
I wondering if can we iterate over the Twig loader filesystem instead?
We should recommend third-party bundles to add their paths through adding them in the bundle config (with PrependExtensionInterface on their DI extension).
Adding paths directly on the filesystem loader is quite fragile, because Symfony is injecting the paths in multiple places, and
I've a use case where that recommendation wouldn't work. For example: a shared third-party bundle aiming to override templates (company design & themes standardization) from others third-party bundles (
This shared bundle will work for our 4.0+ projects only (without
Therefore, reading method calls added on this services (
This shared bundle would also define a new
I think it is possible to detect that situation and inject the right loader, as well as the method calls are copied during this transition:
Still I think that the current logic behind this iterator is quite fragile too and prone to errors, by using the Twig loader we can remove all this logic and rely only on the registered paths. Thus, removing the need to keep updated the iterator
This is just an idea, meanwhile we can merge this as it is.
Can't I use (in my own compiler pass) the
referenced this pull request
Sep 24, 2018
Are you referring to the proposal "iterate over the Twig loader filesystem instead"? I agree, I'll do it soon.
However, we still have to fix this bug on
Even if ppl registering it (manually in Twig
This fix the cache warmup of the overriding convention templates in