Revert "removed an unneeded protected method"

This reverts commit 7de9a57b92.
This commit is contained in:
Fabien Potencier
2015-08-22 14:45:46 +02:00
parent 98b1f31f50
commit 638eedb622
+31 -21
View File
@@ -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, '\\', '/'));