Project

General

Profile

« Previous | Next » 

Revision 1958

Added by darkviper almost 11 years ago

update Twig from version 1.13.1 to 1.13.2

View differences:

Filesystem.php
16 16
 */
17 17
class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderInterface
18 18
{
19
    /** Identifier of the main namespace. */
20
    const MAIN_NAMESPACE = '__main__';
21

  
19 22
    protected $paths;
20 23
    protected $cache;
21 24

  
......
38 41
     *
39 42
     * @return array The array of paths where to look for templates
40 43
     */
41
    public function getPaths($namespace = '__main__')
44
    public function getPaths($namespace = self::MAIN_NAMESPACE)
42 45
    {
43 46
        return isset($this->paths[$namespace]) ? $this->paths[$namespace] : array();
44 47
    }
......
46 49
    /**
47 50
     * Returns the path namespaces.
48 51
     *
49
     * The "__main__" namespace is always defined.
52
     * The main namespace is always defined.
50 53
     *
51 54
     * @return array The array of defined namespaces
52 55
     */
......
61 64
     * @param string|array $paths     A path or an array of paths where to look for templates
62 65
     * @param string       $namespace A path namespace
63 66
     */
64
    public function setPaths($paths, $namespace = '__main__')
67
    public function setPaths($paths, $namespace = self::MAIN_NAMESPACE)
65 68
    {
66 69
        if (!is_array($paths)) {
67 70
            $paths = array($paths);
......
81 84
     *
82 85
     * @throws Twig_Error_Loader
83 86
     */
84
    public function addPath($path, $namespace = '__main__')
87
    public function addPath($path, $namespace = self::MAIN_NAMESPACE)
85 88
    {
86 89
        // invalidate the cache
87 90
        $this->cache = array();
......
101 104
     *
102 105
     * @throws Twig_Error_Loader
103 106
     */
104
    public function prependPath($path, $namespace = '__main__')
107
    public function prependPath($path, $namespace = self::MAIN_NAMESPACE)
105 108
    {
106 109
        // invalidate the cache
107 110
        $this->cache = array();
......
175 178

  
176 179
        $this->validateName($name);
177 180

  
178
        $namespace = '__main__';
181
        $namespace = self::MAIN_NAMESPACE;
179 182
        if (isset($name[0]) && '@' == $name[0]) {
180 183
            if (false === $pos = strpos($name, '/')) {
181 184
                throw new Twig_Error_Loader(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name));

Also available in: Unified diff