What is it for?
This package extends the ExpressionLanguage component of Symfony to compile and evaluate arrays with custom functions.
Installation
composer require php-etl/string-expression-language
Usage
To use the functions provided in this package, you need to add the expression_language
key to your plugin configuration
and use the Kiboko\Component\ArrayExpressionLanguage\ArrayExpressionLanguageProvider
Provider.
expression_language:
- Kiboko\Component\StringExpressionLanguage\StringExpressionLanguageProvider
To determine that a value in your configuration will be a language expression, you must use the @
annotation.
foo: '@=dateTime(input["updated_at"], "YYYY-MM-ddTHH:ii:ss", "Europe/Paris")'
List of available functions
format( string format, mixed ...inputs ) : string
formats a string using the sprintf syntaxtrim( string input ) : string
trims whitespaces from a stringreplace( string search, string replace, string input ) : string
replaces thesearch
values in the string by thereplace
fileName( string path ) : string
extracts the file name from the path namedateTime( string dateTime, string format, string timezone = 'UTC' ) : date
Creates a date object from a formatted dateformatDate( date dateTime, string format ) : string
Transforms a date object into a formatted date string