Documentation

EscaperExtension extends AbstractExtension
in package

FinalYes

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

Methods

__construct()

public __construct([string|false|callable $defaultStrategy = 'html' ]) : mixed
Parameters
$defaultStrategy : string|false|callable = 'html'

An escaping strategy

Tags
see
setDefaultStrategy()

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>

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
int

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>>

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

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

setSafeClasses()

public setSafeClasses([array<string|int, mixed> $safeClasses = [] ]) : void

since Twig 3.10

Parameters
$safeClasses : array<string|int, mixed> = []

        
On this page

Search results