Jobbuddy
Chargement...
Recherche...
Aucune correspondance
Référence de la classe CoreExtension
Graphe d'héritage de CoreExtension:
AbstractExtension LastModifiedExtensionInterface ExtensionInterface

Fonctions membres publiques

 setDateFormat ($format=null, $dateIntervalFormat=null)
 getDateFormat ()
 setTimezone ($timezone)
 getTimezone ()
 setNumberFormat ($decimal, $decimalPoint, $thousandSep)
 getNumberFormat ()
 getTokenParsers ()
 getFilters ()
 getFunctions ()
 getTests ()
 getNodeVisitors ()
 getExpressionParsers ()
 formatDate ($date, $format=null, $timezone=null)
 modifyDate ($date, $modifier)
 convertDate ($date=null, $timezone=null)
 formatNumber ($number, $decimal=null, $decimalPoint=null, $thousandSep=null)
Fonctions membres publiques hérités de AbstractExtension
 getOperators ()
 getLastModified ()

Fonctions membres publiques statiques

static cycle ($values, $position)
static random (string $charset, $values=null, $max=null)
static sprintf ($format,... $values)
static dateConverter (Environment $env, $date, $format=null, $timezone=null)
static replace ($str, $from)
static round ($value, $precision=0, $method='common')
static urlencode ($url)
static merge (... $arrays)
static slice (string $charset, $item, $start, $length=null, $preserveKeys=false)
static first (string $charset, $item)
static last (string $charset, $item)
static join ($value, $glue='', $and=null)
static split (string $charset, $value, $delimiter, $limit=null)
static default ($value, $default='')
static keys ($array)
static invoke (\Closure $arrow,... $arguments)
static reverse (string $charset, $item, $preserveKeys=false)
static shuffle (string $charset, $item)
static sort (Environment $env, $array, $arrow=null)
static inFilter ($value, $compare)
static compare ($a, $b)
static matches (string $regexp, ?string $str)
static trim ($string, $characterMask=null, $side='both')
static nl2br ($string)
static spaceless ($content)
static convertEncoding ($string, $to, $from)
static length (string $charset, $thing)
static upper (string $charset, $string)
static lower (string $charset, $string)
static striptags ($string, $allowable_tags=null)
static titleCase (string $charset, $string)
static capitalize (string $charset, $string)
static callMacro (Template $template, string $method, array $args, int $lineno, array $context, Source $source)
static ensureTraversable ($seq)
static toArray ($seq, $preserveKeys=true)
static testEmpty ($value)
static testSequence ($value)
static testMapping ($value)

Champs de données

const ARRAY_LIKE_CLASSES

Attributs publics statiques

static function
static $context
static $template
static $variables = []
static $withContext = true
static $ignoreMissing = false

Documentation des fonctions membres

◆ capitalize()

capitalize ( string $charset,
$string )
static

Returns a capitalized string.

Paramètres
string | null$stringA string

◆ compare()

compare ( $a,
$b )
static

Compares two values using a more strict version of the PHP non-strict comparison operator.

Voir également
https://wiki.php.net/rfc/string_to_number_comparison
https://wiki.php.net/rfc/trailing_whitespace_numerics

◆ convertDate()

convertDate ( $date = null,
$timezone = null )

Converts an input to a \DateTime instance.

{% if date(user.created_at) < date('+2days') %} {# do something #} {% endif %}

Paramètres
\DateTimeInterface | string | int | null$dateA date, a timestamp or null to use the current time
\DateTimeZone | string | false | null$timezoneThe target timezone, null to use the default, false to leave unchanged
Renvoie
\DateTime|\DateTimeImmutable

◆ convertEncoding()

convertEncoding ( $string,
$to,
$from )
static
Paramètres
string | null$string
string$to
string$from

◆ cycle()

cycle ( $values,
$position )
static

Cycles over a sequence.

Paramètres
array | \ArrayAccess$valuesA non-empty sequence of values
int<0,max>$position The position of the value to return in the cycle
Renvoie
mixed The value at the given position in the sequence, wrapping around as needed

◆ ensureTraversable()

ensureTraversable ( $seq)
static

@template TSequence

Paramètres
TSequence$seq
Renvoie
($seq is iterable ? TSequence : array{})

◆ first()

first ( string $charset,
$item )
static

Returns the first element of the item.

Paramètres
mixed$itemA variable
Renvoie
mixed The first element of the item

◆ formatDate()

formatDate ( $date,
$format = null,
$timezone = null )

Formats a date.

{{ post.published_at|date("m/d/Y") }}

Paramètres
\DateTimeInterface | \DateInterval | string | int | null$dateA date, a timestamp or null to use the current time
string | null$formatThe target format, null to use the default
\DateTimeZone | string | false | null$timezoneThe target timezone, null to use the default, false to leave unchanged

◆ formatNumber()

formatNumber ( $number,
$decimal = null,
$decimalPoint = null,
$thousandSep = null )

Formats a number.

All of the formatting options can be left null, in that case the defaults will be used. Supplying any of the parameters will override the defaults set in the environment object.

Paramètres
mixed$numberA float/int/string of the number to format
int | null$decimalthe number of decimal points to display
string | null$decimalPointthe character(s) to use for the decimal point
string | null$thousandSepthe character(s) to use for the thousands separator

◆ getDateFormat()

getDateFormat ( )

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

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

◆ getExpressionParsers()

getExpressionParsers ( )

Réimplémentée à partir de AbstractExtension.

◆ getFilters()

getFilters ( )

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

Renvoie
TwigFilter[]

Réimplémentée à partir de AbstractExtension.

◆ getFunctions()

getFunctions ( )

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

Renvoie
TwigFunction[]

Réimplémentée à partir de AbstractExtension.

◆ getNodeVisitors()

getNodeVisitors ( )

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

Renvoie
NodeVisitorInterface[]

Réimplémentée à partir de AbstractExtension.

◆ getNumberFormat()

getNumberFormat ( )

Get the default format used by the number_format filter.

Renvoie
array The arguments for number_format()

◆ getTests()

getTests ( )

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

Renvoie
TwigTest[]

Réimplémentée à partir de AbstractExtension.

◆ getTimezone()

getTimezone ( )

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

Renvoie
\DateTimeZone The default timezone currently in use

◆ getTokenParsers()

getTokenParsers ( )

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

Renvoie
TokenParserInterface[]

Réimplémentée à partir de AbstractExtension.

◆ invoke()

invoke ( \Closure $arrow,
... )
static

Invokes a callable.

◆ join()

join ( $value,
$glue = '',
$and = null )
static

Joins the values to a string.

The separators between elements are empty strings per default, you can define them with the optional parameters.

{{ [1, 2, 3]|join(', ', ' and ') }} {# returns 1, 2 and 3 #}

{{ [1, 2, 3]|join('|') }} {# returns 1|2|3 #}

{{ [1, 2, 3]|join }} {# returns 123 #}

Paramètres
iterable | array | string | float | int | bool | null$valueAn array
string$glueThe separator
string | null$andThe separator for the last pair

◆ keys()

keys ( $array)
static

Returns the keys for the given array.

It is useful when you want to iterate over the keys of an array:

{% for key in array|keys %} {# ... #} {% endfor %}

◆ last()

last ( string $charset,
$item )
static

Returns the last element of the item.

Paramètres
mixed$itemA variable
Renvoie
mixed The last element of the item

◆ length()

length ( string $charset,
$thing )
static

Returns the length of a variable.

Paramètres
mixed$thingA variable

◆ lower()

lower ( string $charset,
$string )
static

Converts a string to lowercase.

Paramètres
string | null$stringA string

◆ matches()

matches ( string $regexp,
?string $str )
static
Exceptions
RuntimeErrorWhen an invalid pattern is used

◆ merge()

merge ( ...)
static

Merges any number of arrays or Traversable objects.

{% set items = { 'apple': 'fruit', 'orange': 'fruit' } %}

{% set items = items|merge({ 'peugeot': 'car' }, { 'banana': 'fruit' }) %}

{# items now contains { 'apple': 'fruit', 'orange': 'fruit', 'peugeot': 'car', 'banana': 'fruit' } #}

Paramètres
array|

Traversable ...$arrays Any number of arrays or Traversable objects to merge

◆ modifyDate()

modifyDate ( $date,
$modifier )

Returns a new date object modified.

{{ post.published_at|date_modify("-1day")|date("m/d/Y") }}

Paramètres
\DateTimeInterface | string | int | null$dateA date, a timestamp or null to use the current time
string$modifierA modifier string
Renvoie
\DateTime|\DateTimeImmutable

◆ nl2br()

nl2br ( $string)
static

Inserts HTML line breaks before all newlines in a string.

Paramètres
string | null$string

◆ random()

random ( string $charset,
$values = null,
$max = null )
static

Returns a random value depending on the supplied parameter type:

  • a random item from a \Traversable or array
  • a random character from a string
  • a random integer between 0 and the integer parameter.
Paramètres
\Traversable | array | int | float | string$valuesThe values to pick a random item from
int | null$maxMaximum value used when $values is an int
Renvoie
mixed A random value from the given sequence
Exceptions
RuntimeErrorwhen $values is an empty array (does not apply to an empty string which is returned as is)

◆ replace()

replace ( $str,
$from )
static

Replaces strings within a string.

Paramètres
string | null$strString to replace in
array | \Traversable$fromReplace values

◆ reverse()

reverse ( string $charset,
$item,
$preserveKeys = false )
static

Reverses a variable.

Paramètres
array | \Traversable | string | null$itemAn array, a \Traversable instance, or a string
bool$preserveKeysWhether to preserve key or not
Renvoie
mixed The reversed input

◆ round()

round ( $value,
$precision = 0,
$method = 'common' )
static

Rounds a number.

Paramètres
int | float | string | null$valueThe value to round
int | float$precisionThe rounding precision
'common'|'ceil'|'floor'$method The method to use for rounding
Renvoie
float The rounded number

◆ setDateFormat()

setDateFormat ( $format = null,
$dateIntervalFormat = null )

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

Paramètres
string | null$formatThe default date format string
string | null$dateIntervalFormatThe default date interval format string

◆ setNumberFormat()

setNumberFormat ( $decimal,
$decimalPoint,
$thousandSep )

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

Paramètres
int$decimalthe number of decimal places to use
string$decimalPointthe character(s) to use for the decimal point
string$thousandSepthe character(s) to use for the thousands separator

◆ setTimezone()

setTimezone ( $timezone)

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

Paramètres
\DateTimeZone | string$timezoneThe default timezone string or a \DateTimeZone object

◆ shuffle()

shuffle ( string $charset,
$item )
static

Shuffles an array, a \Traversable instance, or a string. The function does not preserve keys.

Paramètres
array | \Traversable | string | null$item

◆ slice()

slice ( string $charset,
$item,
$start,
$length = null,
$preserveKeys = false )
static

Slices a variable.

Paramètres
mixed$itemA variable
int$startStart of the slice
int$lengthSize of the slice
bool$preserveKeysWhether to preserve key or not (when the input is an array)
Renvoie
mixed The sliced variable

◆ sort()

sort ( Environment $env,
$array,
$arrow = null )
static

Sorts an array.

Paramètres
array | \Traversable$array
?\Closure$arrow

◆ spaceless()

spaceless ( $content)
static

Removes whitespaces between HTML tags.

Paramètres
string | null$content

◆ split()

split ( string $charset,
$value,
$delimiter,
$limit = null )
static

Splits the string into an array.

{{ "one,two,three"|split(',') }} {# returns [one, two, three] #}

{{ "one,two,three,four,five"|split(',', 3) }} {# returns [one, two, "three,four,five"] #}

{{ "123"|split('') }} {# returns [1, 2, 3] #}

{{ "aabbcc"|split('', 2) }} {# returns [aa, bb, cc] #}

Paramètres
string | null$valueA string
string$delimiterThe delimiter
int | null$limitThe limit

◆ sprintf()

sprintf ( $format,
... )
static

Returns a formatted string.

Paramètres
string | null$format

◆ striptags()

striptags ( $string,
$allowable_tags = null )
static

Strips HTML and PHP tags from a string.

Paramètres
string | null$string
string[] | string | null$allowable_tags

◆ testEmpty()

testEmpty ( $value)
static

Checks if a variable is empty.

{# evaluates to true if the foo variable is null, false, or the empty string #} {% if foo is empty %} {# ... #} {% endif %}

Paramètres
mixed$valueA variable

◆ testMapping()

testMapping ( $value)
static

Checks if a variable is a mapping.

{# evaluates to true if the foo variable is a mapping #} {% if foo is mapping %} {# ... #} {% endif %}

◆ testSequence()

testSequence ( $value)
static

Checks if a variable is a sequence.

{# evaluates to true if the foo variable is a sequence #} {% if foo is sequence %} {# ... #} {% endif %}

◆ titleCase()

titleCase ( string $charset,
$string )
static

Returns a titlecased string.

Paramètres
string | null$stringA string

◆ trim()

trim ( $string,
$characterMask = null,
$side = 'both' )
static

Returns a trimmed string.

Paramètres
string | \Stringable | null$string
string | null$characterMask
string$sideleft, right, or both
Exceptions
RuntimeErrorWhen an invalid trimming side is used

◆ upper()

upper ( string $charset,
$string )
static

Converts a string to uppercase.

Paramètres
string | null$stringA string

◆ urlencode()

urlencode ( $url)
static

URL encodes (RFC 3986) a string as a path segment or an array as a query string.

Paramètres
string | array | null$urlA URL or an array of query parameters

Documentation des champs

◆ ARRAY_LIKE_CLASSES

const ARRAY_LIKE_CLASSES
Valeur initiale :
= [
'ArrayIterator',
'ArrayObject',
'CachingIterator',
'RecursiveArrayIterator',
'RecursiveCachingIterator',
'SplDoublyLinkedList',
'SplFixedArray',
'SplObjectStorage',
'SplQueue',
'SplStack',
'WeakMap',
]

◆ function

function
static

Renders a template.

Paramètres
array$context
string | array | TemplateWrapper$templateThe template to render or an array of templates to try consecutively
array$variablesThe variables to pass to the template
bool$withContext
bool$ignoreMissingWhether to ignore missing templates or not
bool$sandboxedWhether to sandbox the template or not

La documentation de cette classe a été générée à partir du fichier suivant :