ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Twig_Extension_Escaper Class Reference

More...

+ Inheritance diagram for Twig_Extension_Escaper:
+ Collaboration diagram for Twig_Extension_Escaper:

Public Member Functions

 __construct ($defaultStrategy='html')
 
 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...
 
 setDefaultStrategy ($defaultStrategy)
 Sets the default strategy to use when not defined by the user. More...
 
 getDefaultStrategy ($name)
 Gets the default strategy to use when not defined by the user. More...
 
 getName ()
 Returns the name of the extension. More...
 
- 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 ()
 

Protected Attributes

 $defaultStrategy
 

Detailed Description

Definition at line 15 of file Escaper.php.

Constructor & Destructor Documentation

◆ __construct()

Twig_Extension_Escaper::__construct (   $defaultStrategy = 'html')
Parameters
string | false | callable$defaultStrategyAn escaping strategy
See also
setDefaultStrategy()

Definition at line 24 of file Escaper.php.

References $defaultStrategy, and setDefaultStrategy().

25  {
27  }
setDefaultStrategy($defaultStrategy)
Sets the default strategy to use when not defined by the user.
Definition: Escaper.php:54
+ Here is the call graph for this function:

Member Function Documentation

◆ getDefaultStrategy()

Twig_Extension_Escaper::getDefaultStrategy (   $name)

Gets the default strategy to use when not defined by the user.

Parameters
string$nameThe template name
Returns
string|false The default strategy to use for the template

Definition at line 83 of file Escaper.php.

References $defaultStrategy, and $name.

84  {
85  // disable string callables to avoid calling a function named html or js,
86  // or any other upcoming escaping strategy
87  if (!is_string($this->defaultStrategy) && false !== $this->defaultStrategy) {
88  return call_user_func($this->defaultStrategy, $name);
89  }
90 
92  }

◆ getFilters()

Twig_Extension_Escaper::getFilters ( )

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

Returns
Twig_SimpleFilter[]

Implements Twig_ExtensionInterface.

Definition at line 39 of file Escaper.php.

40  {
41  return array(
42  new Twig_SimpleFilter('raw', 'twig_raw_filter', array('is_safe' => array('all'))),
43  );
44  }
Represents a template filter.

◆ getName()

Twig_Extension_Escaper::getName ( )

Returns the name of the extension.

Returns
string The extension name
Deprecated:
since 1.26 (to be removed in 2.0), not used anymore internally

Implements Twig_ExtensionInterface.

Definition at line 94 of file Escaper.php.

95  {
96  return 'escaper';
97  }

◆ getNodeVisitors()

Twig_Extension_Escaper::getNodeVisitors ( )

Returns the node visitor instances to add to the existing list.

Returns
Twig_NodeVisitorInterface[]

Implements Twig_ExtensionInterface.

Definition at line 34 of file Escaper.php.

35  {
36  return array(new Twig_NodeVisitor_Escaper());
37  }
Twig_NodeVisitor_Escaper implements output escaping.
Definition: Escaper.php:19

◆ getTokenParsers()

Twig_Extension_Escaper::getTokenParsers ( )

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

Returns
Twig_TokenParserInterface[]

Implements Twig_ExtensionInterface.

Definition at line 29 of file Escaper.php.

30  {
31  return array(new Twig_TokenParser_AutoEscape());
32  }
Marks a section of a template to be escaped or not.
Definition: AutoEscape.php:32

◆ setDefaultStrategy()

Twig_Extension_Escaper::setDefaultStrategy (   $defaultStrategy)

Sets the default strategy to use when not defined by the user.

The strategy can be a valid PHP callback that takes the template name as an argument and returns the strategy to use.

Parameters
string | false | callable$defaultStrategyAn escaping strategy

Definition at line 54 of file Escaper.php.

References $defaultStrategy.

Referenced by __construct().

55  {
56  // for BC
57  if (true === $defaultStrategy) {
58  @trigger_error('Using "true" as the default strategy is deprecated since version 1.21. Use "html" instead.', E_USER_DEPRECATED);
59 
60  $defaultStrategy = 'html';
61  }
62 
63  if ('filename' === $defaultStrategy) {
64  @trigger_error('Using "filename" as the default strategy is deprecated since version 1.27. Use "name" instead.', E_USER_DEPRECATED);
65 
66  $defaultStrategy = 'name';
67  }
68 
69  if ('name' === $defaultStrategy) {
70  $defaultStrategy = array('Twig_FileExtensionEscapingStrategy', 'guess');
71  }
72 
73  $this->defaultStrategy = $defaultStrategy;
74  }
+ Here is the caller graph for this function:

Field Documentation

◆ $defaultStrategy

Twig_Extension_Escaper::$defaultStrategy
protected

Definition at line 17 of file Escaper.php.

Referenced by __construct(), getDefaultStrategy(), and setDefaultStrategy().


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