From 7e5acd1fb382c3f3fbe5f4832a72e542840f9993 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sun, 16 Sep 2012 16:32:36 +0200 Subject: [PATCH] fixed some possible warnings --- lib/Twig/Loader/Filesystem.php | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/Twig/Loader/Filesystem.php b/lib/Twig/Loader/Filesystem.php index 55a43fa..ab0dde2 100644 --- a/lib/Twig/Loader/Filesystem.php +++ b/lib/Twig/Loader/Filesystem.php @@ -105,7 +105,13 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface throw new Twig_Error_Loader(sprintf('The "%s" directory does not exist.', $path)); } - array_unshift($this->paths[$namespace], rtrim($path, '/\\')); + $path = rtrim($path, '/\\'); + + if (!isset($this->paths[$namespace])) { + $this->paths[$namespace][] = $path; + } else { + array_unshift($this->paths[$namespace], $path); + } } /** @@ -161,13 +167,14 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface } $namespace = substr($name, 1, $pos - 1); - if (!isset($this->paths[$namespace])) { - throw new \Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); - } $name = substr($name, $pos + 1); } + if (!isset($this->paths[$namespace])) { + throw new \Twig_Error_Loader(sprintf('There are no registered paths for namespace "%s".', $namespace)); + } + foreach ($this->paths[$namespace] as $path) { if (is_file($path.'/'.$name)) { return $this->cache[$name] = $path.'/'.$name; -- 1.7.2.5