From: Fabien Potencier Date: Fri, 19 Oct 2012 12:32:48 +0000 (+0200) Subject: renamed Twig_ExtendedLoaderInterface to Twig_ExistsLoaderInterface X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=09ba90919e599927188856402ee79c14efebdeab;p=web%2Fkonrad%2Ftwig.git renamed Twig_ExtendedLoaderInterface to Twig_ExistsLoaderInterface --- diff --git a/CHANGELOG b/CHANGELOG index 3784432..db781f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,6 @@ * 1.11.0 (2012-XX-XX) - * n/a + * added Twig_ExistsLoaderInterface (implementing this interface in your loader make the chain loader much faster) * 1.10.3 (2012-10-19) diff --git a/lib/Twig/ExtendedLoaderInterface.php b/lib/Twig/ExistsLoaderInterface.php similarity index 80% rename from lib/Twig/ExtendedLoaderInterface.php rename to lib/Twig/ExistsLoaderInterface.php index 8d59867..90709c6 100644 --- a/lib/Twig/ExtendedLoaderInterface.php +++ b/lib/Twig/ExistsLoaderInterface.php @@ -10,13 +10,12 @@ */ /** - * Interface all loaders must implement in order to provide extra functionality - * for the Twig core. + * Adds an exists() method for loaders. * * @package twig * @author Florin Patan */ -interface Twig_ExtendedLoaderInterface +interface Twig_ExistsLoaderInterface { /** @@ -27,5 +26,4 @@ interface Twig_ExtendedLoaderInterface * @return boolean If the template source code is handled by this loader or not */ public function exists($name); - } diff --git a/lib/Twig/Loader/Array.php b/lib/Twig/Loader/Array.php index dfaf701..e00910c 100644 --- a/lib/Twig/Loader/Array.php +++ b/lib/Twig/Loader/Array.php @@ -20,7 +20,7 @@ * @package twig * @author Fabien Potencier */ -class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExtendedLoaderInterface +class Twig_Loader_Array implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { protected $templates; diff --git a/lib/Twig/Loader/Chain.php b/lib/Twig/Loader/Chain.php index fd767c2..1ab1853 100644 --- a/lib/Twig/Loader/Chain.php +++ b/lib/Twig/Loader/Chain.php @@ -15,7 +15,7 @@ * @package twig * @author Fabien Potencier */ -class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExtendedLoaderInterface +class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { private $hasSourceCache = array(); protected $loaders; @@ -51,7 +51,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExtendedLoaderInte { $exceptions = array(); foreach ($this->loaders as $loader) { - if ($loader instanceof Twig_ExtendedLoaderInterface && !$loader->exists($name)) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { continue; } @@ -75,17 +75,15 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExtendedLoaderInte } foreach ($this->loaders as $loader) { - if ($loader instanceof Twig_ExtendedLoaderInterface) { - if ($loader->exists($name)) { - return $this->hasSourceCache[$name] = true; - } - } else { - try { - $loader->getSource($name); - return $this->hasSourceCache[$name] = true; - } catch (Twig_Error_Loader $e) { - - } + if ($loader instanceof Twig_ExistsLoaderInterface && $loader->exists($name)) { + return $this->hasSourceCache[$name] = true; + } + + try { + $loader->getSource($name); + + return $this->hasSourceCache[$name] = true; + } catch (Twig_Error_Loader $e) { } } @@ -99,7 +97,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExtendedLoaderInte { $exceptions = array(); foreach ($this->loaders as $loader) { - if ($loader instanceof Twig_ExtendedLoaderInterface && !$loader->exists($name)) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { continue; } @@ -120,7 +118,7 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExtendedLoaderInte { $exceptions = array(); foreach ($this->loaders as $loader) { - if ($loader instanceof Twig_ExtendedLoaderInterface && !$loader->exists($name)) { + if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) { continue; } diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 391facf..b201428 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -15,7 +15,7 @@ * @package twig * @author Fabien Potencier */ -class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExtendedLoaderInterface +class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { protected $paths; protected $cache; diff --git a/lib/Twig/Loader/String.php b/lib/Twig/Loader/String.php index 04742cd..5e1b82c 100644 --- a/lib/Twig/Loader/String.php +++ b/lib/Twig/Loader/String.php @@ -24,7 +24,7 @@ * @package twig * @author Fabien Potencier */ -class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExtendedLoaderInterface +class Twig_Loader_String implements Twig_LoaderInterface, Twig_ExistsLoaderInterface { /** * {@inheritdoc}