Skip to content

Commit 22aba90

Browse files
linniksafabpot
authored andcommitted
[TwigBundle] Normalize names of templates and enable cache found templates file names
1 parent 5b3e5e4 commit 22aba90

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/Symfony/Bundle/TwigBundle/Loader/FilesystemLoader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ public function setPaths($paths)
5252

5353
protected function findTemplate($name)
5454
{
55-
list($tpl, $options) = $this->nameParser->parse($name);
56-
5755
// normalize name
58-
$tpl = preg_replace('#/{2,}#', '/', strtr($tpl, '\\', '/'));
56+
$name = str_replace(':/' , ':', preg_replace('#/{2,}#', '/', strtr($name, '\\', '/')));
5957

60-
if (isset($this->cache[$tpl])) {
61-
return $this->cache[$tpl];
58+
if (isset($this->cache[$name])) {
59+
return $this->cache[$name];
6260
}
6361

62+
list($tpl, $options) = $this->nameParser->parse($name);
63+
6464
$this->validateName($tpl);
6565
$this->validateName($options['bundle']);
6666
$this->validateName($options['controller']);
@@ -80,7 +80,7 @@ protected function findTemplate($name)
8080
$this->logger->info(sprintf('Loaded template file "%s"', $file));
8181
}
8282

83-
return $file;
83+
return $this->cache[$name] = $file;
8484
}
8585

8686
if (null !== $this->logger) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy