34b71d27eae26b2415e36e5ced0be037c8af4a6f
[yaffs-website] / vendor / twig / twig / lib / Twig / Extension / Staging.php
1 <?php
2
3 /*
4  * This file is part of Twig.
5  *
6  * (c) Fabien Potencier
7  *
8  * For the full copyright and license information, please view the LICENSE
9  * file that was distributed with this source code.
10  */
11
12 /**
13  * Internal class.
14  *
15  * This class is used by Twig_Environment as a staging area and must not be used directly.
16  *
17  * @author Fabien Potencier <fabien@symfony.com>
18  *
19  * @internal
20  */
21 class Twig_Extension_Staging extends Twig_Extension
22 {
23     protected $functions = array();
24     protected $filters = array();
25     protected $visitors = array();
26     protected $tokenParsers = array();
27     protected $globals = array();
28     protected $tests = array();
29
30     public function addFunction($name, $function)
31     {
32         if (isset($this->functions[$name])) {
33             @trigger_error(sprintf('Overriding function "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
34         }
35
36         $this->functions[$name] = $function;
37     }
38
39     public function getFunctions()
40     {
41         return $this->functions;
42     }
43
44     public function addFilter($name, $filter)
45     {
46         if (isset($this->filters[$name])) {
47             @trigger_error(sprintf('Overriding filter "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
48         }
49
50         $this->filters[$name] = $filter;
51     }
52
53     public function getFilters()
54     {
55         return $this->filters;
56     }
57
58     public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
59     {
60         $this->visitors[] = $visitor;
61     }
62
63     public function getNodeVisitors()
64     {
65         return $this->visitors;
66     }
67
68     public function addTokenParser(Twig_TokenParserInterface $parser)
69     {
70         if (isset($this->tokenParsers[$parser->getTag()])) {
71             @trigger_error(sprintf('Overriding tag "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $parser->getTag()), E_USER_DEPRECATED);
72         }
73
74         $this->tokenParsers[$parser->getTag()] = $parser;
75     }
76
77     public function getTokenParsers()
78     {
79         return $this->tokenParsers;
80     }
81
82     public function addGlobal($name, $value)
83     {
84         $this->globals[$name] = $value;
85     }
86
87     public function getGlobals()
88     {
89         return $this->globals;
90     }
91
92     public function addTest($name, $test)
93     {
94         if (isset($this->tests[$name])) {
95             @trigger_error(sprintf('Overriding test "%s" that is already registered is deprecated since version 1.30 and won\'t be possible anymore in 2.0.', $name), E_USER_DEPRECATED);
96         }
97
98         $this->tests[$name] = $test;
99     }
100
101     public function getTests()
102     {
103         return $this->tests;
104     }
105
106     public function getName()
107     {
108         return 'staging';
109     }
110 }