added Twig_Loader_Filesystem::prependPath()

This commit is contained in:
Fabien Potencier
2012-07-14 16:15:01 +02:00
parent 657de7bdeb
commit c24ea1bcc1
3 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
* 1.9.2 (2012-XX-XX)
* n/a
* added Twig_Loader_Filesystem::prependPath()
* 1.9.1 (2012-07-22)
+6
View File
@@ -142,6 +142,12 @@ With such a configuration, Twig will first look for templates in
``$templateDir1`` and if they do not exist, it will fallback to look for them
in the ``$templateDir2``.
You can add or prepend paths via the ``addPath()`` and ``prependPath()``
methods::
$loader->addPath($templateDir3);
$loader->prependPath($templateDir4);
``Twig_Loader_String``
......................
+17
View File
@@ -74,6 +74,23 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface
$this->paths[] = rtrim($path, '/\\');
}
/**
* Prepends a path where templates are stored.
*
* @param string $path A path where to look for templates
*/
public function prependPath($path)
{
// invalidate the cache
$this->cache = array();
if (!is_dir($path)) {
throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path));
}
array_unshift($this->paths, rtrim($path, '/\\'));
}
/**
* Gets the source code of a template, given its name.
*