Skip to content

Support Twig chain loaders if available#2660

Merged
bobdenotter merged 1 commit intobolt:4.1from
emodric:fix_twig_chain_loaders
Jul 1, 2021
Merged

Support Twig chain loaders if available#2660
bobdenotter merged 1 commit intobolt:4.1from
emodric:fix_twig_chain_loaders

Conversation

@emodric
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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