Transformations configuration¶
A number of properties relate to transforming the data during the import process. All of these properties are used during the “Transform data” step. They are sub-properties of the transformations property.
Properties¶
Property | Data type | Step/Scope |
---|---|---|
mapping | Mapping configuration | Transform data |
rteEnabled | boolean | Transform data |
trim | boolean | Transform data |
userFunc | array | Transform data |
userFunction | array | Transform data |
value | simple type (string, integer, boolean) | Transform data |
mapping¶
- Type
- Mapping configuration
- Description
- This property can be used to map values from the external data to values coming from some internal table. A typical example might be to match 2-letter country ISO codes to the uid of the “static_countries” table.
- Scope
- Transform data
value¶
- Type
- Simple type (string, integer, boolean)
- Description
- With this property, it is possible to set a fixed value for a given field. For example, this might be used to set a flag for all imported records.
- Scope
- Transform data
trim¶
- Type
- boolean
- Description
- If set to
true
, every value for this column will be trimmed during the transformation step. - Scope
- Transform data
rteEnabled¶
- Type
- boolean
- Description
- If set to
true
when importing HTML data into a RTE-enable field, the imported data will go through the usual RTE transformation process on the way to the database. - Scope
- Transform data
userFunc¶
- Type
- array
- Description
- This property has been renamed userFunction. Backwards-compatibility is ensured for now, but please update your configuration as soon as possible.
- Scope
- Transform data
userFunction¶
- Type
- array
- Description
This property can be used to define a function that will be called on each record to transform the data from the given field. See example below.
Example
Here is a sample setup referencing a user function:
$GLOBALS['TCA']['fe_users']['columns']['starttime']['external'] = [ 0 => [ 'field' => 'start_date', 'transformations' => [ 10 => [ 'userFunction' => [ 'class' => \Cobweb\ExternalImport\Task\DateTimeTransformation::class, 'method' => 'parseDate' ] ] ] ] ];
The definition of a user function takes three parameters:
- class
- (string) Required. Name of the class to be instantiated.
- method
- (string) Required. Name of the method that should be called.
- parameters (formerly “params”)
- (array) Optional. Can contain any number of data, which will be passed to the method. This used to be called “params”. Backwards-compatibility is ensured for now, but please update your configuration as soon as possible.
In the example above we are using a sample class provided by External Import that can be used to parse a date and either return it as a timestamp or format it using either of the PHP functions
date()
orstrftime()
.For more details about creating a user function, please refer to the Developer’s Guide.
- Scope
- Transform data