Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | yes |
RFC? | no |
Symfony version | 3.1.8 |
On our application we're using in some places the twig namespace syntax (@namespace/folder1/template.html.twig
) and in templates that uses embed
twig uses the SF TemplateReference
to get the logical name which leads to the SF syntax (Bundle:folder1:template.html.twig
).
What happens is that twig loader loads @namespace/folder1/template.html.twig
but fails on Bundle:folder1:template.html.twig
then SF filesystem loader is used as fallback. The problem is that twig loader uses realpath()
since v1.27
and SF loader doesn't.
I've solved that on our application by overriding SF loader and using realpath()
as well but although it works fine I'm not 100% sure if that's the way to go (that's why I didn't send a PR):
use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
final class TemplateLoader extends FilesystemLoader
{
protected function findTemplate($template, $throw = true)
{
$file = parent::findTemplate($template, $throw);
if ($absolutePath = realpath($file)) {
$file = $absolutePath;
}
return $this->cache[(string) $template] = $file;
}
}