Overriding the way Twig finds the views?

Viewed 79

I'm new to Symfony, and so far I just love it!

Right now, I'm playing around with different personal hobby projects and I've come across something I do not seem to be able to wrap my head around.


I'm running Symfony 3.3.6 right now. I'm trying to kind of add a theme functionality to my project. Right now, I've got my Bundles that got their own views, which I can overwrite inside of app/Resources/views/. So right now, out of the box Symfony kind of supports a base view, with overwriting possibility.

What I would like to achieve is one more level of fallback.

I would like to make twig FIRST look into a theme folder, where the [THEME] would be a config.

1) Look for file inside of /app/theme/[THEME]/resources/view 2) Look for file inside of /app/theme/[THEME]/resources/[BUNDLE]/view


I would also like this to happen from inside a bundle, for example ThemeBundle.

Basically I would like to have a Bundle, that would take of the logic for Twig on how to find the views. It's really important that all the code, right now, would still work. So I do not wish to add a a path variable or something similar, but I would actually like to modify the behavior of TwigBundle from my own Bundle!

Is this sort of thing possible?

1 Answers
Related