AttributeExtension
extends AbstractExtension
in package
Define Twig filters, functions, and tests with PHP attributes.
Tags
Table of Contents
Properties
- $class : string
- $filters : array<string|int, mixed>
- $functions : array<string|int, mixed>
- $tests : array<string|int, mixed>
Methods
- __construct() : mixed
- Use a runtime class using PHP attributes to define filters, functions, and tests.
- getClass() : class-string
- 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.
- initFromAttributes() : void
- needsEnvironment() : bool
- Detect if the first argument of the method is the environment.
Properties
$class
private
string
$class
$filters
private
array<string|int, mixed>
$filters
$functions
private
array<string|int, mixed>
$functions
$tests
private
array<string|int, mixed>
$tests
Methods
__construct()
Use a runtime class using PHP attributes to define filters, functions, and tests.
public
__construct(class-string $class) : mixed
Parameters
- $class : class-string
getClass()
public
getClass() : class-string
Return values
class-stringgetExpressionParsers()
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>initFromAttributes()
private
initFromAttributes() : void
needsEnvironment()
Detect if the first argument of the method is the environment.
private
needsEnvironment(ReflectionFunctionAbstract $function) : bool
Parameters
- $function : ReflectionFunctionAbstract