10000 bug #24710 [TwigBridge] Fix template paths in profiler (ro0NL) · symfony/symfony@98dae3e · GitHub
[go: up one dir, main page]

Skip to content

Commit 98dae3e

Browse files
committed
bug #24710 [TwigBridge] Fix template paths in profiler (ro0NL)
This PR was merged into the 3.4 branch. Discussion ---------- [TwigBridge] Fix template paths in profiler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes/no | Fixed tickets | #24540 | License | MIT | Doc PR | symfony/symfony-docs#... <!--highly recommended for new features--> Fixes the profiler being unavailable with non filesystem templates. ![image](https://user-images.githubusercontent.com/1047696/32117680-87866354-bb4f-11e7-9cb9-428ad6751a1e.png) Commits ------- c9174df [TwigBridge] Fix template paths in profiler
2 parents 1e7d487 + c9174df commit 98dae3e

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)
0