added a setPaths() method to the filesystem loader
authorfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Wed, 14 Oct 2009 05:12:46 +0000 (05:12 +0000)
committerfabien <fabien@93ef8e89-cb99-4229-a87c-7fa0fa45744b>
Wed, 14 Oct 2009 05:12:46 +0000 (05:12 +0000)
git-svn-id: http://svn.twig-project.org/trunk@39 93ef8e89-cb99-4229-a87c-7fa0fa45744b

lib/Twig/Loader/Filesystem.php

index a6f5de9..9ce3956 100644 (file)
@@ -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