EscaperExtension
extends AbstractExtension
in package
Table of Contents
Properties
- $defaultStrategy : mixed
- $environment : mixed
- $escaper : mixed
- $escapers : mixed
Methods
- __construct() : mixed
- addSafeClass() : void
- getDefaultStrategy() : string|false
- Gets the default strategy to use when not defined by the user.
- getEscapers() : array<string, callable(Environment, string, string): string>
- Gets all defined escapers.
- getExpressionParsers() : array<string|int, mixed>
- getFilters() : array<string|int, TwigFilter>
- Returns a list of filters to add to the existing list.
- getFunctions() : array<string|int, TwigFunction>
- Returns a list of functions to add to the existing list.
- getLastModified() : int
- Returns the last modification time of the extension for cache invalidation.
- getNodeVisitors() : array<string|int, NodeVisitorInterface>
- Returns the node visitor instances to add to the existing list.
- getOperators() : array<string|int, array<string|int, mixed>>
- Returns a list of operators to add to the existing list.
- getTests() : array<string|int, TwigTest>
- Returns a list of tests to add to the existing list.
- getTokenParsers() : array<string|int, TokenParserInterface>
- Returns the token parser instances to add to the existing list.
- setDefaultStrategy() : void
- Sets the default strategy to use when not defined by the user.
- setEnvironment() : void
- setEscaper() : void
- Defines a new escaper to be used via the escape filter.
- setEscaperRuntime() : void
- setSafeClasses() : void
Properties
$defaultStrategy
private
mixed
$defaultStrategy
$environment
private
mixed
$environment
$escaper
private
mixed
$escaper
$escapers
private
mixed
$escapers
= []
Methods
__construct()
public
__construct([string|false|callable $defaultStrategy = 'html' ]) : mixed
Parameters
- $defaultStrategy : string|false|callable = 'html'
-
An escaping strategy
Tags
addSafeClass()
public
addSafeClass(string $class, array<string|int, mixed> $strategies) : void
since Twig 3.10
Parameters
- $class : string
- $strategies : array<string|int, mixed>
getDefaultStrategy()
Gets the default strategy to use when not defined by the user.
public
getDefaultStrategy(string $name) : string|false
Parameters
- $name : string
-
The template name
Return values
string|false —The default strategy to use for the template
getEscapers()
Gets all defined escapers.
public
getEscapers() : array<string, callable(Environment, string, string): string>
since Twig 3.10
Return values
array<string, callable(Environment, string, string): string> —An array of escapers
getExpressionParsers()
public
getExpressionParsers() : array<string|int, mixed>
Return values
array<string|int, mixed>getFilters()
Returns a list of filters to add to the existing list.
public
getFilters() : array<string|int, TwigFilter>
Return values
array<string|int, TwigFilter>getFunctions()
Returns a list of functions to add to the existing list.
public
getFunctions() : array<string|int, TwigFunction>
Return values
array<string|int, TwigFunction>getLastModified()
Returns the last modification time of the extension for cache invalidation.
public
getLastModified() : int
This timestamp should be the last time the source code of the extension class and all its dependencies were modified (including the Runtime class).
Return values
intgetNodeVisitors()
Returns the node visitor instances to add to the existing list.
public
getNodeVisitors() : array<string|int, NodeVisitorInterface>
Return values
array<string|int, NodeVisitorInterface>getOperators()
Returns a list of operators to add to the existing list.
public
getOperators() : array<string|int, array<string|int, mixed>>
Return values
array<string|int, array<string|int, mixed>>getTests()
Returns a list of tests to add to the existing list.
public
getTests() : array<string|int, TwigTest>
Return values
array<string|int, TwigTest>getTokenParsers()
Returns the token parser instances to add to the existing list.
public
getTokenParsers() : array<string|int, TokenParserInterface>
Return values
array<string|int, TokenParserInterface>setDefaultStrategy()
Sets the default strategy to use when not defined by the user.
public
setDefaultStrategy(string|false|callable(string $templateName): string $defaultStrategy) : void
The strategy can be a valid PHP callback that takes the template name as an argument and returns the strategy to use.
Parameters
- $defaultStrategy : string|false|callable(string $templateName): string
-
An escaping strategy
setEnvironment()
public
setEnvironment(Environment $environment) : void
since Twig 3.10
Parameters
- $environment : Environment
setEscaper()
Defines a new escaper to be used via the escape filter.
public
setEscaper(string $strategy, callable(Environment, string, string): string $callable) : void
since Twig 3.10
Parameters
- $strategy : string
-
The strategy name that should be used as a strategy in the escape call
- $callable : callable(Environment, string, string): string
-
A valid PHP callable
setEscaperRuntime()
public
setEscaperRuntime(EscaperRuntime $escaper) : void
since Twig 3.10
Parameters
- $escaper : EscaperRuntime
setSafeClasses()
public
setSafeClasses([array<string|int, mixed> $safeClasses = [] ]) : void
since Twig 3.10
Parameters
- $safeClasses : array<string|int, mixed> = []