Twig API
Class

Twig_Extension_Core

class Twig_Extension_Core extends Twig_Extension

Methods

initRuntime(Twig_Environment $environment)

Initializes the runtime environment.

from Twig_Extension
array getTokenParsers()

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

array getNodeVisitors()

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

from Twig_Extension
array getFilters()

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

array getTests()

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

array getFunctions()

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

array getOperators()

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

array getGlobals()

Returns a list of global variables to add to the existing list.

from Twig_Extension
setDateFormat(string $format = null, string $dateIntervalFormat = null)

Sets the default format to be used by the date filter.

array getDateFormat()

Gets the default format to be used by the date filter.

setTimezone(DateTimeZone|string $timezone)

Sets the default timezone to be used by the date filter.

DateTimeZone getTimezone()

Gets the default timezone to be used by the date filter.

setNumberFormat(integer $decimal, string $decimalPoint, string $thousandSep)

Sets the default format to be used by the number_format filter.

array getNumberFormat()

Get the default format used by the number_format filter.

parseNotTestExpression(Twig_Parser $parser, $node)

parseTestExpression(Twig_Parser $parser, $node)

string getName()

Returns the name of the extension.

Details

in Twig_Extension at line 20
public initRuntime(Twig_Environment $environment)

Initializes the runtime environment.

This is where you can load some file that contains filter functions for instance.

Parameters

Twig_Environment $environment The current Twig_Environment instance

at line 99
public array getTokenParsers()

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

Return Value

array An array of Twig_TokenParser instances

in Twig_Extension at line 39
public array getNodeVisitors()

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

Return Value

array An array of Twig_NodeVisitorInterface instances

at line 125
public array getFilters()

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

Return Value

array An array of filters

at line 203
public array getTests()

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

Return Value

array An array of tests

at line 186
public array getFunctions()

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

Return Value

array An array of global functions

at line 224
public array getOperators()

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

Return Value

array An array of operators

in Twig_Extension at line 89
public array getGlobals()

Returns a list of global variables to add to the existing list.

Return Value

array An array of global variables

at line 27
public setDateFormat(string $format = null, string $dateIntervalFormat = null)

Sets the default format to be used by the date filter.

Parameters

string $format The default date format string
string $dateIntervalFormat The default date interval format string

at line 43
public array getDateFormat()

Gets the default format to be used by the date filter.

Return Value

array The default date format string and the default date interval format string

at line 53
public setTimezone(DateTimeZone|string $timezone)

Sets the default timezone to be used by the date filter.

Parameters

DateTimeZone|string $timezone The default timezone string or a DateTimeZone object

at line 63
public DateTimeZone getTimezone()

Gets the default timezone to be used by the date filter.

Return Value

DateTimeZone The default timezone currently in use

at line 79
public setNumberFormat(integer $decimal, string $decimalPoint, string $thousandSep)

Sets the default format to be used by the number_format filter.

Parameters

integer $decimal The number of decimal places to use.
string $decimalPoint The character(s) to use for the decimal point.
string $thousandSep The character(s) to use for the thousands separator.

at line 89
public array getNumberFormat()

Get the default format used by the number_format filter.

Return Value

array The arguments for number_format()

at line 261
public parseNotTestExpression(Twig_Parser $parser, $node)

Parameters

Twig_Parser $parser
$node

at line 266
public parseTestExpression(Twig_Parser $parser, $node)

Parameters

Twig_Parser $parser
$node

at line 305
public string getName()

Returns the name of the extension.

Return Value

string The extension name