added Twig_Loader_Filesystem::addPath()

This commit is contained in:
Fabien Potencier
2011-06-07 16:33:55 +02:00
parent 7e457209f8
commit cd0e749308
+18 -8
View File
@@ -47,23 +47,33 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface
*/
public function setPaths($paths)
{
// invalidate the cache
$this->cache = array();
if (!is_array($paths)) {
$paths = array($paths);
}
$this->paths = array();
foreach ($paths as $path) {
if (!is_dir($path)) {
throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
}
$this->paths[] = $path;
$this->addPath($path);
}
}
/**
* Adds a path where templates are stored.
*
* @param string $path A path where to look for templates
*/
public function addPath($path)
{
// invalidate the cache
$this->cache = array();
if (!is_dir($path)) {
throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
}
$this->paths[] = $path;
}
/**
* Gets the source code of a template, given its name.
*