From: fabien Date: Wed, 14 Oct 2009 05:12:46 +0000 (+0000) Subject: added a setPaths() method to the filesystem loader X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=f601832cf97a1e0049ff6febb99337393893376b;p=konrad%2Ftwig.git added a setPaths() method to the filesystem loader git-svn-id: http://svn.twig-project.org/trunk@39 93ef8e89-cb99-4229-a87c-7fa0fa45744b --- diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index a6f5de9..9ce3956 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -31,16 +31,7 @@ class Twig_Loader_Filesystem extends Twig_Loader */ public function __construct($paths, $cache = null, $autoReload = true) { - if (!is_array($paths)) - { - $paths = array($paths); - } - - $this->paths = array(); - foreach ($paths as $path) - { - $this->paths[] = realpath($path); - } + $this->setPaths($paths); parent::__construct($cache, $autoReload); } @@ -56,6 +47,25 @@ class Twig_Loader_Filesystem extends Twig_Loader } /** + * Sets the paths where templates are stored. + * + * @param string|array $paths A path or an array of paths where to look for templates + */ + public function setPaths($paths) + { + if (!is_array($paths)) + { + $paths = array($paths); + } + + $this->paths = array(); + foreach ($paths as $path) + { + $this->paths[] = realpath($path); + } + } + + /** * Gets the source code of a template, given its name. * * @param string $name string The name of the template to load