1 | <?php |
||
43 | class Twig extends AbstractEngine |
||
44 | { |
||
45 | |||
46 | /** |
||
47 | * @readwrite |
||
48 | * @var \Twig_Loader_Filesystem |
||
49 | */ |
||
50 | protected $loader; |
||
51 | |||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | private $optionsMap = [ |
||
56 | 'debug' => 'debug', |
||
57 | 'autoEscape' => 'autoescape', |
||
58 | 'strictVariables' => 'strict_variables', |
||
59 | 'autoReload' => 'auto_reload', |
||
60 | 'cache' => 'cache', |
||
61 | 'baseTemplateClass' => 'base_template_class', |
||
62 | 'charset' => 'charset', |
||
63 | 'optimizations' => 'optimizations' |
||
64 | ]; |
||
65 | |||
66 | /** |
||
67 | * @readwrite |
||
68 | * @var \Twig_Environment |
||
69 | */ |
||
70 | protected $twigEnvironment; |
||
71 | |||
72 | /** |
||
73 | * @write |
||
74 | * @var \Twig_Template |
||
75 | */ |
||
76 | protected $template; |
||
77 | |||
78 | /** |
||
79 | * @readwrite |
||
80 | * @var string|false |
||
81 | */ |
||
82 | protected $cache = false; |
||
83 | |||
84 | /** |
||
85 | * @readwrite |
||
86 | * @var string |
||
87 | */ |
||
88 | protected $charset = 'utf8'; |
||
89 | |||
90 | /** |
||
91 | * @readwrite |
||
92 | * @var string |
||
93 | */ |
||
94 | protected $baseTemplateClass = 'Twig_Template'; |
||
95 | |||
96 | /** |
||
97 | * @readwrite |
||
98 | * @var bool |
||
99 | */ |
||
100 | protected $autoReload = false; |
||
101 | |||
102 | /** |
||
103 | * @readwrite |
||
104 | * @var bool |
||
105 | */ |
||
106 | protected $strictVariables = false; |
||
107 | |||
108 | /** |
||
109 | * @readwrite |
||
110 | * @var bool|string |
||
111 | */ |
||
112 | protected $autoEscape = true; |
||
113 | |||
114 | /** |
||
115 | * @readwrite |
||
116 | * @var int |
||
117 | */ |
||
118 | protected $optimizations = -1; |
||
119 | |||
120 | /** |
||
121 | * @readwrite |
||
122 | * @var bool |
||
123 | */ |
||
124 | protected $debug = false; |
||
125 | |||
126 | /** |
||
127 | * @readwrite |
||
128 | * @var array |
||
129 | */ |
||
130 | protected $locations = []; |
||
131 | |||
132 | /** |
||
133 | * Parses the source template code. |
||
134 | * |
||
135 | * @param string $source The template to parse |
||
136 | * |
||
137 | * @return TemplateEngineInterface|self|$this |
||
138 | * |
||
139 | * @throws ParserException If any error occurs parsing the template |
||
140 | */ |
||
141 | 4 | public function parse($source) |
|
155 | |||
156 | /** |
||
157 | * Processes the template with data to produce the final output. |
||
158 | * |
||
159 | * @param mixed $data The data that will be used to process the view. |
||
160 | * |
||
161 | * @return string Returns processed output string. |
||
162 | */ |
||
163 | 4 | public function process($data = array()) |
|
175 | |||
176 | /** |
||
177 | * Sets the list of available locations for template files. |
||
178 | * |
||
179 | * @param array $locations |
||
180 | * |
||
181 | * @return TemplateEngineInterface|self|$this |
||
182 | */ |
||
183 | 14 | public function setLocations(array $locations) |
|
188 | |||
189 | |||
190 | /** |
||
191 | * Returns the source template engine |
||
192 | * |
||
193 | * @return \Twig_Environment |
||
194 | */ |
||
195 | 2 | public function getSourceEngine() |
|
199 | |||
200 | /** |
||
201 | * Gets the twig environment object |
||
202 | * |
||
203 | * @return \Twig_Environment |
||
204 | */ |
||
205 | 6 | protected function getTwigEnvironment() |
|
215 | |||
216 | /** |
||
217 | * Creates a file system loader |
||
218 | * |
||
219 | * @return \Twig_Loader_Filesystem |
||
220 | */ |
||
221 | 4 | protected function getLoader() |
|
230 | |||
231 | /** |
||
232 | * Returns current configured options |
||
233 | * |
||
234 | * @return array |
||
235 | */ |
||
236 | 2 | protected function getOptions() |
|
244 | } |
||
245 |