summaryrefslogtreecommitdiff
path: root/inc/lib/Twig/Loader/Filesystem.php
diff options
context:
space:
mode:
authorczaks <marcin@6irc.net>2013-11-11 21:54:35 +0100
committerczaks <marcin@6irc.net>2013-11-11 21:54:35 +0100
commitf5657caf24753ed7c25d56659ae8dfe79d48b99a (patch)
tree989f1149070194f18f6250c851159dda813151fe /inc/lib/Twig/Loader/Filesystem.php
parent0a58973631626879abeea4956b33cc2b56dea453 (diff)
parent9fb63b053fbb552a2a8bbde1e230a8b73296fb6d (diff)
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard into vichan-devel-4.5
Conflicts: inc/config.php install.php post.php stylesheets/style.css
Diffstat (limited to 'inc/lib/Twig/Loader/Filesystem.php')
-rw-r--r--inc/lib/Twig/Loader/Filesystem.php27
1 files changed, 15 insertions, 12 deletions
diff --git a/inc/lib/Twig/Loader/Filesystem.php b/inc/lib/Twig/Loader/Filesystem.php
index f9211cbd..23bac47d 100644
--- a/inc/lib/Twig/Loader/Filesystem.php
+++ b/inc/lib/Twig/Loader/Filesystem.php
@@ -16,8 +16,11 @@
*/
class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
{
- protected $paths;
- protected $cache;
+ /** Identifier of the main namespace. */
+ const MAIN_NAMESPACE = '__main__';
+
+ protected $paths = array();
+ protected $cache = array();
/**
* Constructor.
@@ -38,7 +41,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
*
* @return array The array of paths where to look for templates
*/
- public function getPaths($namespace = '__main__')
+ public function getPaths($namespace = self::MAIN_NAMESPACE)
{
return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
}
@@ -46,7 +49,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
/**
* Returns the path namespaces.
*
- * The "__main__" namespace is always defined.
+ * The main namespace is always defined.
*
* @return array The array of defined namespaces
*/
@@ -61,7 +64,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
* @param string|array $paths A path or an array of paths where to look for templates
* @param string $namespace A path namespace
*/
- public function setPaths($paths, $namespace = '__main__')
+ public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
{
if (!is_array($paths)) {
$paths = array($paths);
@@ -81,7 +84,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
*
* @throws Twig_Error_Loader
*/
- public function addPath($path, $namespace = '__main__')
+ public function addPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = array();
@@ -101,7 +104,7 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
*
* @throws Twig_Error_Loader
*/
- public function prependPath($path, $namespace = '__main__')
+ public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
{
// invalidate the cache
$this->cache = array();
@@ -175,15 +178,15 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
$this->validateName($name);
- $namespace = '__main__';
+ $namespace = self::MAIN_NAMESPACE;
+ $shortname = $name;
if (isset($name[0]) && '@' == $name[0]) {
if (false === $pos = strpos($name, '/')) {
throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));
}
$namespace = substr($name, 1, $pos - 1);
-
- $name = substr($name, $pos + 1);
+ $shortname = substr($name, $pos + 1);
}
if (!isset($this->paths[$namespace])) {
@@ -191,8 +194,8 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
}
foreach ($this->paths[$namespace] as $path) {
- if (is_file($path.'/'.$name)) {
- return $this->cache[$name] = $path.'/'.$name;
+ if (is_file($path.'/'.$shortname)) {
+ return $this->cache[$name] = $path.'/'.$shortname;
}
}