*/
/**
- * 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 <florinpatan@gmail.com>
*/
-interface Twig_ExtendedLoaderInterface
+interface Twig_ExistsLoaderInterface
{
/**
* @return boolean If the template source code is handled by this loader or not
*/
public function exists($name);
-
}
* @package twig
* @author Fabien Potencier <fabien@symfony.com>
*/
-class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExtendedLoaderInterface
+class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
{
private $hasSourceCache = array();
protected $loaders;
{
$exceptions = array();
foreach ($this->loaders as $loader) {
- if ($loader instanceof Twig_ExtendedLoaderInterface && !$loader->exists($name)) {
+ if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
continue;
}
}
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) {
}
}
{
$exceptions = array();
foreach ($this->loaders as $loader) {
- if ($loader instanceof Twig_ExtendedLoaderInterface && !$loader->exists($name)) {
+ if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
continue;
}
{
$exceptions = array();
foreach ($this->loaders as $loader) {
- if ($loader instanceof Twig_ExtendedLoaderInterface && !$loader->exists($name)) {
+ if ($loader instanceof Twig_ExistsLoaderInterface && !$loader->exists($name)) {
continue;
}