19 private $hasSourceCache = array();
29 $this->loaders = array();
42 $this->loaders[] = $loader;
43 $this->hasSourceCache = array();
51 $exceptions = array();
52 foreach ($this->loaders as $loader) {
58 return $loader->getSource($name);
60 $exceptions[] = $e->getMessage();
64 throw new Twig_Error_Loader(sprintf(
'Template "%s" is not defined (%s).', $name, implode(
', ', $exceptions)));
72 $name = (string) $name;
74 if (isset($this->hasSourceCache[$name])) {
75 return $this->hasSourceCache[$name];
78 foreach ($this->loaders as $loader) {
80 if ($loader->exists($name)) {
81 return $this->hasSourceCache[$name] =
true;
88 $loader->getSource($name);
90 return $this->hasSourceCache[$name] =
true;
95 return $this->hasSourceCache[$name] =
false;
103 $exceptions = array();
104 foreach ($this->loaders as $loader) {
110 return $loader->getCacheKey($name);
112 $exceptions[] = get_class($loader).
': '.$e->getMessage();
116 throw new Twig_Error_Loader(sprintf(
'Template "%s" is not defined (%s).', $name, implode(
' ', $exceptions)));
124 $exceptions = array();
125 foreach ($this->loaders as $loader) {
131 return $loader->isFresh($name, $time);
133 $exceptions[] = get_class($loader).
': '.$e->getMessage();
137 throw new Twig_Error_Loader(sprintf(
'Template "%s" is not defined (%s).', $name, implode(
' ', $exceptions)));
getSource($name)
{Gets the source code of a template, given its name.The name of the template to loadstring The templa...
addLoader(Twig_LoaderInterface $loader)
Adds a loader instance.
exists($name)
{Check if we have the source code of a template, given its name.The name of the template to check if ...
getCacheKey($name)
{Gets the cache key to use for the cache for a given template name.The name of the template to loadst...
Adds an exists() method for loaders.
Interface all loaders must implement.
Loads templates from other loaders.
exists($name)
Check if we have the source code of a template, given its name.
__construct(array $loaders=array())
Constructor.
Exception thrown when an error occurs during template loading.
isFresh($name, $time)
{Returns true if the template is still fresh.The template name The last modification time of the cach...