From 638eedb622bb1bc2aaa51b3553c5a1213d746b5f Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 22 Aug 2015 14:45:46 +0200 Subject: [PATCH] Revert "removed an unneeded protected method" This reverts commit 7de9a57b9232a2992eff9aebcd718c361cd121d3. --- lib/Twig/Loader/Filesystem.php | 52 ++++++++++++++++++++-------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 769a110f5..b57655619 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -143,9 +143,40 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface * {@inheritdoc} */ public function exists($name) + { + return $this->doFindTemplate($this->normalizeName($name)); + } + + /** + * {@inheritdoc} + */ + public function isFresh($name, $time) + { + return filemtime($this->findTemplate($name)) <= $time; + } + + protected function findTemplate($name) { $name = $this->normalizeName($name); + if ($this->doFindTemplate($name)) { + return $this->cache[$name]; + } + + throw new Twig_Error_Loader($this->errorCache[$name]); + } + + /** + * Checks if the template can be found. + * + * @param string $name The template name + * + * @return bool true if the template exists, false otherwise + */ + protected function doFindTemplate($name) + { + $this->validateName($name); + if (isset($this->cache[$name])) { return true; } @@ -154,8 +185,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface return false; } - $this->validateName($name); - list($namespace, $shortname) = $this->parseName($name); if (!isset($this->paths[$namespace])) { @@ -183,25 +212,6 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface return false; } - /** - * {@inheritdoc} - */ - public function isFresh($name, $time) - { - return filemtime($this->findTemplate($name)) <= $time; - } - - protected function findTemplate($name) - { - $name = $this->normalizeName($name); - - if ($this->exists($name)) { - return $this->cache[$name]; - } - - throw new Twig_Error_Loader($this->errorCache[$name]); - } - protected function normalizeName($name) { return preg_replace('#/{2,}#', '/', strtr($name, '\\', '/'));