ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
TwigTestExtension Class Reference
+ Inheritance diagram for TwigTestExtension:
+ Collaboration diagram for TwigTestExtension:

Public Member Functions

 getTokenParsers ()
 Returns the token parser instances to add to the existing list. More...
 
 getFilters ()
 Returns a list of filters to add to the existing list. More...
 
 getFunctions ()
 Returns a list of functions to add to the existing list. More...
 
 getTests ()
 Returns a list of tests to add to the existing list. More...
 
 §Filter ($value)
 
 §Function ($value)
 
 escape_and_nl2br ($env, $value, $sep='< br/>')
 nl2br which also escapes, for testing escaper filters. More...
 
 nl2br ($value, $sep='< br/>')
 nl2br only, for testing filters with pre_escape. More...
 
 dynamic_path ($element, $item)
 
 dynamic_foo ($foo, $bar, $item)
 
 escape_something ($value)
 
 preserves_safety ($value)
 
 br ()
 
 is_multi_word ($value)
 
 __call ($method, $arguments)
 
- Public Member Functions inherited from Twig_Extension
 initRuntime (Twig_Environment $environment)
 
 getTokenParsers ()
 Returns the token parser instances to add to the existing list. More...
 
 getNodeVisitors ()
 Returns the node visitor instances to add to the existing list. More...
 
 getFilters ()
 Returns a list of filters to add to the existing list. More...
 
 getTests ()
 Returns a list of tests to add to the existing list. More...
 
 getFunctions ()
 Returns a list of functions to add to the existing list. More...
 
 getOperators ()
 Returns a list of operators to add to the existing list. More...
 
 getGlobals ()
 
 getName ()
 
 initRuntime (Twig_Environment $environment)
 Initializes the runtime environment. More...
 
 getTokenParsers ()
 Returns the token parser instances to add to the existing list. More...
 
 getNodeVisitors ()
 Returns the node visitor instances to add to the existing list. More...
 
 getFilters ()
 Returns a list of filters to add to the existing list. More...
 
 getTests ()
 Returns a list of tests to add to the existing list. More...
 
 getFunctions ()
 Returns a list of functions to add to the existing list. More...
 
 getOperators ()
 Returns a list of operators to add to the existing list. More...
 
 getGlobals ()
 Returns a list of global variables to add to the existing list. More...
 
 getName ()
 Returns the name of the extension. More...
 

Static Public Member Functions

static staticCall ($value)
 
static __callStatic ($method, $arguments)
 

Detailed Description

Definition at line 127 of file IntegrationTest.php.

Member Function Documentation

◆ __call()

TwigTestExtension::__call (   $method,
  $arguments 
)

Definition at line 237 of file IntegrationTest.php.

238 {
239 if ('magicCall' !== $method) {
240 throw new BadMethodCallException('Unexpected call to __call');
241 }
242
243 return 'magic_'.$arguments[0];
244 }

◆ __callStatic()

static TwigTestExtension::__callStatic (   $method,
  $arguments 
)
static

Definition at line 246 of file IntegrationTest.php.

247 {
248 if ('magicStaticCall' !== $method) {
249 throw new BadMethodCallException('Unexpected call to __callStatic');
250 }
251
252 return 'static_magic_'.$arguments[0];
253 }

◆ br()

TwigTestExtension::br ( )

Definition at line 227 of file IntegrationTest.php.

228 {
229 return '<br />';
230 }

◆ dynamic_foo()

TwigTestExtension::dynamic_foo (   $foo,
  $bar,
  $item 
)

Definition at line 207 of file IntegrationTest.php.

208 {
209 return $foo.'/'.$bar.'/'.$item;
210 }

◆ dynamic_path()

TwigTestExtension::dynamic_path (   $element,
  $item 
)

Definition at line 202 of file IntegrationTest.php.

203 {
204 return $element.'/'.$item;
205 }

◆ §Function()

TwigTestExtension::§Function (   $value)

Definition at line 179 of file IntegrationTest.php.

180 {
181 return "§{$value}§";
182 }

◆ escape_and_nl2br()

TwigTestExtension::escape_and_nl2br (   $env,
  $value,
  $sep = '<br />' 
)

nl2br which also escapes, for testing escaper filters.

Definition at line 187 of file IntegrationTest.php.

188 {
189 return $this->nl2br(twig_escape_filter($env, $value, 'html'), $sep);
190 }
$env
nl2br($value, $sep='< br/>')
nl2br only, for testing filters with pre_escape.

References $env, and nl2br().

+ Here is the call graph for this function:

◆ getTokenParsers()

TwigTestExtension::getTokenParsers ( )

Returns the token parser instances to add to the existing list.

Returns
Twig_TokenParserInterface[]

Reimplemented from Twig_Extension.

Definition at line 129 of file IntegrationTest.php.

130 {
131 return array(
133 );
134 }

◆ nl2br()

TwigTestExtension::nl2br (   $value,
  $sep = '<br />' 
)

nl2br only, for testing filters with pre_escape.

Definition at line 195 of file IntegrationTest.php.

196 {
197 // not secure if $value contains html tags (not only entities)
198 // don't use
199 return str_replace("\n", "$sep\n", $value);
200 }

Referenced by escape_and_nl2br().

+ Here is the caller graph for this function:

◆ §Filter()

TwigTestExtension::§Filter (   $value)

Definition at line 174 of file IntegrationTest.php.

175 {
176 return "§{$value}§";
177 }

◆ escape_something()

TwigTestExtension::escape_something (   $value)

Definition at line 212 of file IntegrationTest.php.

213 {
214 return strtoupper($value);
215 }

◆ getFilters()

TwigTestExtension::getFilters ( )

Returns a list of filters to add to the existing list.

Returns
Twig_SimpleFilter[]

Reimplemented from Twig_Extension.

Definition at line 136 of file IntegrationTest.php.

137 {
138 return array(
139 new Twig_SimpleFilter('§', array($this, '§Filter')),
140 new Twig_SimpleFilter('escape_and_nl2br', array($this, 'escape_and_nl2br'), array('needs_environment' => true, 'is_safe' => array('html'))),
141 new Twig_SimpleFilter('nl2br', array($this, 'nl2br'), array('pre_escape' => 'html', 'is_safe' => array('html'))),
142 new Twig_SimpleFilter('escape_something', array($this, 'escape_something'), array('is_safe' => array('something'))),
143 new Twig_SimpleFilter('preserves_safety', array($this, 'preserves_safety'), array('preserves_safety' => array('html'))),
144 new Twig_SimpleFilter('static_call_string', 'TwigTestExtension::staticCall'),
145 new Twig_SimpleFilter('static_call_array', array('TwigTestExtension', 'staticCall')),
146 new Twig_SimpleFilter('magic_call', array($this, 'magicCall')),
147 new Twig_SimpleFilter('magic_call_string', 'TwigTestExtension::magicStaticCall'),
148 new Twig_SimpleFilter('magic_call_array', array('TwigTestExtension', 'magicStaticCall')),
149 new Twig_SimpleFilter('*_path', array($this, 'dynamic_path')),
150 new Twig_SimpleFilter('*_foo_*_bar', array($this, 'dynamic_foo')),
151 );
152 }
Represents a template filter.

◆ getFunctions()

TwigTestExtension::getFunctions ( )

Returns a list of functions to add to the existing list.

Returns
Twig_SimpleFunction[]

Reimplemented from Twig_Extension.

Definition at line 154 of file IntegrationTest.php.

155 {
156 return array(
157 new Twig_SimpleFunction('§', array($this, '§Function')),
158 new Twig_SimpleFunction('safe_br', array($this, 'br'), array('is_safe' => array('html'))),
159 new Twig_SimpleFunction('unsafe_br', array($this, 'br')),
160 new Twig_SimpleFunction('static_call_string', 'TwigTestExtension::staticCall'),
161 new Twig_SimpleFunction('static_call_array', array('TwigTestExtension', 'staticCall')),
162 new Twig_SimpleFunction('*_path', array($this, 'dynamic_path')),
163 new Twig_SimpleFunction('*_foo_*_bar', array($this, 'dynamic_foo')),
164 );
165 }
Represents a template function.

◆ getTests()

TwigTestExtension::getTests ( )

Returns a list of tests to add to the existing list.

Returns
Twig_SimpleTest[]

Reimplemented from Twig_Extension.

Definition at line 167 of file IntegrationTest.php.

168 {
169 return array(
170 new Twig_SimpleTest('multi word', array($this, 'is_multi_word')),
171 );
172 }
Represents a template test.
Definition: SimpleTest.php:20

◆ is_multi_word()

TwigTestExtension::is_multi_word (   $value)

Definition at line 232 of file IntegrationTest.php.

233 {
234 return false !== strpos($value, ' ');
235 }

◆ preserves_safety()

TwigTestExtension::preserves_safety (   $value)

Definition at line 217 of file IntegrationTest.php.

218 {
219 return strtoupper($value);
220 }

◆ staticCall()

static TwigTestExtension::staticCall (   $value)
static

Definition at line 222 of file IntegrationTest.php.

223 {
224 return "*$value*";
225 }

The documentation for this class was generated from the following file: