Skip to content
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 Twig chain loaders if available #2660

Merged
merged 1 commit into from
Jul 1, 2021

Conversation

emodric
Copy link
Contributor

@emodric emodric commented Jun 30, 2021

One of our Symfony bundles that we're testing on Bolt uses a custom Twig loader.

This results in $this->getTwig()->getLoader() code used in Bolt in several places to return an instance of Twig\Loader\ChainLoader instead of Twig\Loader\FilesystemLoader making the code in question fail in Bolt, which results in Bolt not being able to find any of its templates.

This fix adds support for ChainLoader, which basically iterates over any Twig loader in the chain loader, and if it is an instance of FilesystemLoader, does what Bolt did previously (adds or prepends a new path, based on context).

Thanks to @ilukac for discovering the cause of the issue.

Copy link
Member

@bobdenotter bobdenotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't bumped into this yet, but I can see how this would be problematic. Thanks for the fix, @emodric and @ilukac 👍

@bobdenotter bobdenotter merged commit 5ae13c3 into bolt:4.1 Jul 1, 2021
@emodric
Copy link
Contributor Author

emodric commented Jul 1, 2021

Thanks @bobdenotter !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants