1
|
<?php
|
2
|
|
3
|
/*
|
4
|
* This file is part of Twig.
|
5
|
*
|
6
|
* (c) 2012 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
|
$this->functions[$name] = $function;
|
33
|
}
|
34
|
|
35
|
public function getFunctions()
|
36
|
{
|
37
|
return $this->functions;
|
38
|
}
|
39
|
|
40
|
public function addFilter($name, $filter)
|
41
|
{
|
42
|
$this->filters[$name] = $filter;
|
43
|
}
|
44
|
|
45
|
public function getFilters()
|
46
|
{
|
47
|
return $this->filters;
|
48
|
}
|
49
|
|
50
|
public function addNodeVisitor(Twig_NodeVisitorInterface $visitor)
|
51
|
{
|
52
|
$this->visitors[] = $visitor;
|
53
|
}
|
54
|
|
55
|
public function getNodeVisitors()
|
56
|
{
|
57
|
return $this->visitors;
|
58
|
}
|
59
|
|
60
|
public function addTokenParser(Twig_TokenParserInterface $parser)
|
61
|
{
|
62
|
$this->tokenParsers[] = $parser;
|
63
|
}
|
64
|
|
65
|
public function getTokenParsers()
|
66
|
{
|
67
|
return $this->tokenParsers;
|
68
|
}
|
69
|
|
70
|
public function addGlobal($name, $value)
|
71
|
{
|
72
|
$this->globals[$name] = $value;
|
73
|
}
|
74
|
|
75
|
public function getGlobals()
|
76
|
{
|
77
|
return $this->globals;
|
78
|
}
|
79
|
|
80
|
public function addTest($name, $test)
|
81
|
{
|
82
|
$this->tests[$name] = $test;
|
83
|
}
|
84
|
|
85
|
public function getTests()
|
86
|
{
|
87
|
return $this->tests;
|
88
|
}
|
89
|
|
90
|
public function getName()
|
91
|
{
|
92
|
return 'staging';
|
93
|
}
|
94
|
}
|