Skip to content

Commit c9174df

Browse files
committed
[TwigBridge] Fix template paths in profiler
1 parent fdac9e3 commit c9174df

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Symfony/Bridge/Twig/DataCollector/TwigDataCollector.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,18 @@ public function lateCollect()
6363
$this->data['template_paths'] = array();
6464

6565
$templateFinder = function (Profile $profile) use (&$templateFinder) {
66-
if ($profile->isTemplate() && $template = $this->twig->load($profile->getName())->getSourceContext()->getPath()) {
67-
$this->data['template_paths'][$profile->getName()] = $template;
66+
if ($profile->isTemplate()) {
67+
try {
68+
$template = $this->twig->load($name = $profile->getName());
69+
} catch (\Twig_Error_Loader $e) {
70+
$template = null;
71+
}
72+
73+
if (null !== $template && '' !== $path = $template->getSourceContext()->getPath()) {
74+
$this->data['template_paths'][$name] = $path;
75+
}
6876
}
77+
6978
foreach ($profile as $p) {
7079
$templateFinder($p);
7180
}

0 commit comments

Comments
 (0)