From cd0e749308e8692ab7aee15b71c220d20c3088bc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 7 Jun 2011 16:33:55 +0200 Subject: [PATCH] added Twig_Loader_Filesystem::addPath() --- lib/Twig/Loader/Filesystem.php | 24 +++++++++++++++++------- 1 files changed, 17 insertions(+), 7 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index b4a3887..08e9c2c 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -47,21 +47,31 @@ 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->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(); - $this->paths[] = $path; + if (!is_dir($path)) { + throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); } + + $this->paths[] = $path; } /** -- 1.7.2.5