mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 11:27:00 +00:00
added Twig_Loader_Filesystem::prependPath()
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
* 1.9.2 (2012-XX-XX)
|
||||
|
||||
* n/a
|
||||
* added Twig_Loader_Filesystem::prependPath()
|
||||
|
||||
* 1.9.1 (2012-07-22)
|
||||
|
||||
|
||||
@@ -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``
|
||||
......................
|
||||
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user