Skip to content

Commit 7678562

Browse files
committed
merged branch lsmith77/template_locator (PR #2128)
Commits ------- afc0971 make it easier to customize the cache lookup in the TemplateLocator Discussion ---------- make it easier to customize the cache lookup in the TemplateLocator --------------------------------------------------------------------------- by fabpot at 2011/09/22 01:21:56 -0700 Do you any use case for that? --------------------------------------------------------------------------- by lsmith77 at 2011/09/22 01:27:06 -0700 Yes in the ThemeBundle we override the default cache to include the key + theme: https://github.com/liip/liipthemebundle/pull/9/files#L7R53 --------------------------------------------------------------------------- by lsmith77 at 2011/09/22 01:29:18 -0700 though i just thought about it .. if we do not put this into 2.0, it might not be worth the trouble. --------------------------------------------------------------------------- by pjedrzejewski at 2011/09/22 02:19:42 -0700 +1 for this.
2 parents 7c7a607 + e3b9daf commit 7678562

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Templating/Loader/TemplateLocator.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,18 @@ public function __construct(FileLocatorInterface $locator, $cacheDir = null)
4040
$this->locator = $locator;
4141
}
4242

43+
/**
44+
* Returns a full path for a given file.
45+
*
46+
* @param TemplateReferenceInterface $template A template
47+
*
48+
* @return string The full path for the file
49+
*/
50+
protected function getCacheKey($template)
51+
{
52+
return $template->getLogicalName();
53+
}
54+
4355
/**
4456
* Returns a full path for a given file.
4557
*
@@ -58,7 +70,7 @@ public function locate($template, $currentPath = null, $first = true)
5870
throw new \InvalidArgumentException("The template must be an instance of TemplateReferenceInterface.");
5971
}
6072

61-
$key = $template->getLogicalName();
73+
$key = $this->getCacheKey($template);
6274

6375
if (isset($this->cache[$key])) {
6476
return $this->cache[$key];

0 commit comments

Comments
 (0)