Skip to content

Commit 4384cbb

Browse files
authored
Updated documentation for expression language packages (#44)
* Updated documentation for expression language packages * Updated Akeneo Expression Language page's summary
1 parent 4bcfc66 commit 4384cbb

File tree

3 files changed

+68
-21
lines changed

3 files changed

+68
-21
lines changed

content/connectivity/akeneo/expression-language.en.md

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@ weight: 2
1010

1111
- [What is it ?](#what-is-it-)
1212
- [Installation](#installation)
13-
- [Usage](#usage)
14-
- [Functions reference](#functions-reference)
15-
- [Attribute data manipulation](#attribute-data-manipulation)
16-
- [Filter by locale](#filter-by-locale)
17-
- [Filter by scope](#filter-by-scope)
18-
- [Take the first available value by scopes](#take-the-first-available-value-by-scopes)
19-
- [Combining results filter](#combining-results-filter)
20-
- [Excluding results filter](#excluding-results-filter)
21-
- [Extracting a slice of the values list](#extracting-a-slice-of-the-values-list)
22-
- [Extracting the beginning of the values list](#extracting-the-beginning-of-the-values-list)
23-
- [Extracting the end of the values list](#extracting-the-end-of-the-values-list)
24-
- [Extracting the values list, after an offset](#extracting-the-values-list-after-an-offset)
25-
- [Extracting the first value from the list](#extracting-the-first-value-from-the-list)
26-
- [Extracting the last value from the list](#extracting-the-last-value-from-the-list)
27-
- [Dates management with dateTime and dateTimeZone](#dates-management-with-datetime-and-datetimezone)
28-
- [Manage metrics with metricAmount, metricUnit and formatMetric](#manage-metrics-with-metricamount-metricunit-and-formatmetric)
29-
13+
- [Filter Provider](#filter-provider)
14+
- [Usage](#usage)
15+
- [Functions reference](#functions-reference)
16+
- [Attribute data manipulation](#attribute-data-manipulation)
17+
- [Filter by locale](#filter-by-locale)
18+
- [Filter by scope](#filter-by-scope)
19+
- [Take the first available value by scopes](#take-the-first-available-value-by-scopes)
20+
- [Combining results filter](#combining-results-filter)
21+
- [Excluding results filter](#excluding-results-filter)
22+
- [Extracting a slice of the values list](#extracting-a-slice-of-the-values-list)
23+
- [Extracting the beginning of the values list](#extracting-the-beginning-of-the-values-list)
24+
- [Extracting the end of the values list](#extracting-the-end-of-the-values-list)
25+
- [Extracting the values list, after an offset](#extracting-the-values-list-after-an-offset)
26+
- [Extracting the first value from the list](#extracting-the-first-value-from-the-list)
27+
- [Extracting the last value from the list](#extracting-the-last-value-from-the-list)
28+
- [Dates management with dateTime and dateTimeZone](#dates-management-with-datetime-and-datetimezone)
29+
- [Manage metrics with metricAmount, metricUnit and formatMetric](#manage-metrics-with-metricamount-metricunit-and-formatmetric)
30+
- [Builder Provider](#builder-provider)
31+
- [Usage](#builder-provider)
32+
- [Functions reference](#builder-provider)
33+
3034
## What is it ?
3135

3236
This library implements functions for manipulating Akeneo API data through the
@@ -38,7 +42,9 @@ This library implements functions for manipulating Akeneo API data through the
3842
composer require php-etl/akeneo-expression-language
3943
```
4044

41-
## Usage
45+
## Filter Provider
46+
47+
### Usage
4248

4349
To use Akeneo's expression language functions, you must first add the `expression_language` key and put in
4450
the provider `Kiboko\Component\ExpressionLanguage\Akeneo\AkeneoFilterProvider`.
@@ -98,9 +104,9 @@ $interpreter->evaluate($expression, ['input' => $input]);
98104

99105
{{< /tabs >}}
100106

101-
## Functions reference
107+
### Functions reference
102108

103-
### Attribute data manipulation
109+
#### Attribute data manipulation
104110

105111
Akeneo has a specific data format that would make cumbersome the data mapping
106112
if there were no dedicated tools. In this matter the Expression Language functions
@@ -715,3 +721,40 @@ This function will extract the unit part of a metric attribute's value
715721
`formatMetric(array $attribut, string $locale)`
716722

717723
This function will format the metric according to the specified locale
724+
725+
## Builder Provider
726+
727+
The Akeneo API expects you to have certain types of format for your attributes.
728+
The functions provided by the AkeneoBuilderProvider allow you to create the expected formats easily.
729+
730+
### Usage
731+
732+
To use the Akeneo's Builder expression language, you must first add the `expression_language` key and put in
733+
the provider `Kiboko\Component\ExpressionLanguage\Akeneo\AkeneoBuilderProvider`.
734+
735+
Then, in the fields that can use expression languages, you can use any [functions](#builder-functions-reference) provided by
736+
the Akeneo Builder provider.
737+
738+
{{< tabs name="basic_definition" >}}
739+
740+
{{< tab name="YAML" codelang="yaml" >}}
741+
- fastmap:
742+
expression_language:
743+
- 'Kiboko\Component\ExpressionLanguage\Akeneo\AkeneoBuilderProvider'
744+
map:
745+
- field: '[title]'
746+
expression: 'withValue(input["title"])'
747+
{{< /tab >}}
748+
749+
{{< /tabs >}}
750+
751+
### Functions reference
752+
753+
|Name|Description|Example|
754+
|---|---|---|
755+
|build(`string` ...values)|Enables several values to be grouped together in a single ordered array corresponding to the format that the API expects.|build(input["values"])|
756+
|withValue(`string` value, `string` locale, `string` scope)|Creates the expected format for attributes of type single-line text, multi-line text, boolean, date, number, measurement.|withValue(input["variant_name"], "fr_FR", "ecommerce")|
757+
|withSimpleOption(`string` code, `string` attribute, `string` labels, `string` locale = 'null', `string` scope = 'null')|Creates the expected format for single-option attributes.|build(withSimpleOption("PHY","kind", {"fr_FR": "PHY"}))|
758+
|withMultipleOption(`string` codes, `string` attribute, `string` labels, `string` locale, `string` scope)|Creates the expected format for multiple-option attributes.|withMultipleOption(input["collection"], "collection", {"fr_FR": "My collection"}, "fr_FR", "ecommerce")|
759+
|withReferenceEntityValue(`string` value, `string` locale = 'null', `string` channel = 'null')|Creates the expected format for reference entity record attributes of type single-line text, multi-line text, boolean, date, number, measurement.|withReferenceEntityValue(input["label"], "fr_FR")|
760+
|withReferenceEntitySimpleOption(`string` value, `string` locale = 'null', `string` channel = 'null')|Creates the expected format for simple-select reference entity record attributes.|withReferenceEntitySimpleOption(input["associated_crops_code"], "fr_FR")|

content/feature/expression-language/satellite-expression-functions/_index.en.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ foo: '@=env("MY_ENVIRONMENT_VARIABLE")'
3838

3939
## List of available functions
4040

41-
| Name | Desctiption |
41+
| Name | Description |
4242
|----------------------------------------------------|-----------------------------------------------------|
4343
| env(`string` name): `string`&vert;`false` | Gets the value of an environment variable |
4444
| envAsFile(`string` name): `string` | Create a file whose name is an environment variable |

content/feature/expression-language/string-expression-functions/_index.en.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,7 @@ foo: '@=dateTime(input["updated_at"], "YYYY-MM-ddTHH:ii:ss", "Europe/Paris")'
6464
| dateTime(`string` dateTime, `string` format, `string` timezone = 'UTC'): `date` | Creates a date object from a formatted date |
6565
| formatDate(`date` dateTime, `string` format): `string` | Transforms a date object into a formatted date string |
6666
| now(`string` timezone): `string` | Returns a new \DateTime object with the given timezone |
67+
| convertCharCode(`string` text, `string` sourceCharCode, `string` destinationCharCode): `string` | Converts a string from one character encoding to another |
68+
| asFloat(`string` value): `string` | Converts the value into a float number |
69+
| asInteger(`string` value): `string` | Converts the value to an integer |
70+
| asString(`string` value): `string` | Converts the value into a string |

0 commit comments

Comments
 (0)