PHP Class Common\Core\Twig\Extensions\BaseTwigModifiers

These filters work independent of front/backend.
Show file Open project: forkcms/forkcms

Public Methods

Method Description
camelCase ( string $string ) : string CamelCase Converter.
formatCurrency ( string $string, string $currency = 'EUR', integer $decimals = null ) : string Format a number as currency syntax: {{ $string|formatcurrency($currency, $decimals) }}.
formatNumber ( string $number, integer $decimals = null ) : string Fallback for if our parent functions don't implement this method
highlightCode ( string $string ) : string Highlights all strings in tags.
lowercase ( string $string ) : string Makes this string lowercase.
random ( integer $min, integer $max ) : integer Get a random var between a min and max syntax: {{ rand($min, $max) }}.
showBool ( string | boolean $status, boolean $reverse = false ) : string Shows a v or x to indicate the boolean state (Y|N, j|n, true|false).
snakeCase ( string $string ) : string snakeCase Converter.
spoonDate ( mixed $timestamp, string[optional] $format = 'Y-m-d H:i:s', string[optional] $language = 'en' ) : string Formats a language specific date.
stripNewlines ( string $string ) : string Convert a multi line string into a string without newlines so it can be handles by JS syntax: {{ $string|stripnewlines }}.
truncate ( string $string, integer $length, boolean $useHellip = true, boolean $closestWord = false ) : string Truncate a string syntax: {{ $string|truncate($max-length, $append-hellip, $closest-word) }}.
uppercase ( string $string ) : string Transform the string to uppercase.

Method Details

camelCase() public static method

syntax: {{ $string|camelcase }}.
public static camelCase ( string $string ) : string
$string string
return string

formatCurrency() public static method

Format a number as currency syntax: {{ $string|formatcurrency($currency, $decimals) }}.
public static formatCurrency ( string $string, string $currency = 'EUR', integer $decimals = null ) : string
$string string The string to form.
$currency string The currency to will be used to format the number.
$decimals integer The number of decimals to show.
return string

formatNumber() public static method

Fallback for if our parent functions don't implement this method
public static formatNumber ( string $number, integer $decimals = null ) : string
$number string
$decimals integer
return string

highlightCode() public static method

syntax: {{ $string|highlight }}.
public static highlightCode ( string $string ) : string
$string string The string passed from the template.
return string

lowercase() public static method

syntax: {{ $string|lowercase }}.
public static lowercase ( string $string ) : string
$string string The string that you want to apply this method on.
return string The string, completely lowercased.

random() public static method

Get a random var between a min and max syntax: {{ rand($min, $max) }}.
public static random ( integer $min, integer $max ) : integer
$min integer The minimum random number.
$max integer The maximum random number.
return integer

showBool() public static method

syntax: {{ showbool($status, $reverse) }}.
public static showBool ( string | boolean $status, boolean $reverse = false ) : string
$status string | boolean
$reverse boolean show the opposite of the status
return string

snakeCase() public static method

syntax: {{ $string|snakecase }}.
public static snakeCase ( string $string ) : string
$string string
return string

spoonDate() public static method

syntax: {{ $timestamp|spoondate($format, $language) }}.
public static spoonDate ( mixed $timestamp, string[optional] $format = 'Y-m-d H:i:s', string[optional] $language = 'en' ) : string
$timestamp mixed The timestamp or date that you want to apply the format to.
$format string[optional]
$language string[optional]
return string The formatted date according to the timestamp, format and provided language.

stripNewlines() public static method

Convert a multi line string into a string without newlines so it can be handles by JS syntax: {{ $string|stripnewlines }}.
public static stripNewlines ( string $string ) : string
$string string The variable that should be processed.
return string

truncate() public static method

Truncate a string syntax: {{ $string|truncate($max-length, $append-hellip, $closest-word) }}.
public static truncate ( string $string, integer $length, boolean $useHellip = true, boolean $closestWord = false ) : string
$string string The string passed from the template.
$length integer The maximum length of the truncated string.
$useHellip boolean Should a hellip be appended if the length exceeds the requested length?
$closestWord boolean Truncate on exact length or on closest word?
return string

uppercase() public static method

syntax: {{ $string|uppercase }}.
public static uppercase ( string $string ) : string
$string string The string that you want to apply this method on.
return string The string, completly uppercased.