From c9174dff7c3eb92de0df68240e12db8790fd4625 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Fri, 27 Oct 2017 19:43:59 +0200 Subject: [PATCH] [TwigBridge] Fix template paths in profiler --- .../Bridge/Twig/DataCollector/TwigDataCollector.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php index 66f2a764e7617..c1956974f8f99 100644 --- a/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php +++ b/src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php @@ -63,9 +63,18 @@ public function lateCollect() $this->data['template_paths'] = array(); $templateFinder = function (Profile $profile) use (&$templateFinder) { - if ($profile->isTemplate() && $template = $this->twig->load($profile->getName())->getSourceContext()->getPath()) { - $this->data['template_paths'][$profile->getName()] = $template; + if ($profile->isTemplate()) { + try { + $template = $this->twig->load($name = $profile->getName()); + } catch (\Twig_Error_Loader $e) { + $template = null; + } + + if (null !== $template && '' !== $path = $template->getSourceContext()->getPath()) { + $this->data['template_paths'][$name] = $path; + } } + foreach ($profile as $p) { $templateFinder($p); }