General TCA configuration

Here is an example of a typical general section syntax, containing two import configurations.

Each configuration must be identified with a key (in the example below, 0 and 'api'). The same keys need to be used again in the column configuration.

$GLOBALS['TCA']['tx_externalimporttest_tag'] = [
'external' => [
     'general' => [
          0 => [
               'connector' => 'csv',
               'parameters' => [
                    'filename' => 'EXT:externalimport_test/Resources/Private/ImportData/Test/Tags.txt',
                    'delimiter' => ';',
                    'text_qualifier' => '"',
                    'encoding' => 'utf8',
                    'skip_rows' => 1
               ],
               'data' => 'array',
               'referenceUid' => 'code',
               'priority' => 5000,
               'description' => 'List of tags'
          ],
          'api' => [
               'data' => 'array',
               'referenceUid' => 'code',
               'description' => 'Tags defined via the import API'
          ]
     ]
],
];

All available properties are described below.

Properties

Property Data type Scope/Step
additionalFields string Read data
arrayPath string Handle data (array)
arrayPathFlatten bool Handle data (array)
arrayPathSeparator string Handle data (array)
clearCache string Clear cache
connector string Read data
customSteps array Any step
data string Read data
dataHandler string Handle data
description string Display
disabledOperations string Store data
disableLog boolean Store data
enforcePid boolean Store data
group string Sync process
minimumRecords integer Validate data
namespaces array Handle data (XML)
nodetype string Handle data (XML)
nodepath string Handle data (XML)
parameters array Read data
pid integer Store data
priority integer Display/automated import
referenceUid string Store data
updateSlugs boolean Store data
useColumnIndex string or integer Configuration
whereClause string Store data

connector

Type
string
Description

Connector service subtype.

Must be defined only for pulling data. Leave blank for pushing data. You will need to install the relevant connector extension. Here is a list of available extensions and their corresponding types:

Type Extension
csv svconnector_csv
json svconnector_json
sql svconnector_sql
feed svconnector_feed
Scope
Read data

parameters

Type
array
Description

Array of parameters that must be passed to the connector service.

Not used when pushing data.

Scope
Read data

data

Type
string
Description
The format in which the data is returned by the connector service. Can be either xml or array.
Scope
Read data

dataHandler

Type
string
Description
A class name for replacing the standard data handlers. See the Developer’s Guide for more details.
Scope
Handle data

group

Type
string
Description
This can be any arbitrary string of characters. All External Import configurations having the same value for the “group” property will form a group of configurations. It is then possible to execute the synchronization of all configurations in the group in one go, in order of priority (lowest goes first). Group synchronization is available on the command line and in the Scheduler task.
Scope
Sync process

nodetype

Type
string
Description
Name of the reference nodes inside the XML structure, i.e. the children of these nodes correspond to the data that goes into the database fields (see also the description of the field attribute).
Scope
Handle data (XML)

nodepath

Type
string
Description
XPath expression for selecting the reference nodes inside the XML structure. This is an alternative to the nodetype property and will take precedence if both are defined.
Scope
Handle data (XML)

arrayPath

Type
string
Description

Pointer to a sub-array inside the incoming external data, as a list of keys separated by some marker. The sub-array pointed to will be used as the source of data in the subsenquent steps, rather than the whole structure that was read during the ReadDataStep.

For more details on usage and available options, see the dedicated page.

Scope
Handle data (array)

arrayPathFlatten

Type
bool
Description

When the special * segment is used in an arrayPath, the resulting structure is always an array. If the arrayPath target is actually a single value, this may not be desirable. When arrayPathFlatten is set to true, the result is preserved as a simple type.

Note

If the arrayPath property uses the special * segment several times, arrayPathFlatten will apply only to the last occurrence. The reason is that the method which traverses the array structure is called recursively on each * segment. When the result of the final call is flattened, a simple type is returned back up the call chain, which means that arrayPathFlatten has no further effect.

Scope
Handle data (array)

arrayPathSeparator

Type
string
Description
Separator to use in the arrayPath property. Defaults to / if this property is not defined.
Scope
Handle data (array)

referenceUid

Type
string
Description

Name of the column where the equivalent of a primary key for the external data is stored.

Important

This is the name of a field in the TYPO3 CMS database, not in the external data! It is the field where the reference (or primary) key of the external data is stored.

Scope
Store data

priority

Type
integer
Description

A level of priority for the execution of the synchronization. Some tables may need to be synchronized before others if foreign relations are to be established. This gives a clue to the user and a strict order for scheduled synchronizations (either when synchronizing all configurations or when synchronizing a group).

The lowest priority value goes first.

If priority is not defined, a default value of 1000 is applied (defined by class constant \Cobweb\ExternalImport\Importer::DEFAULT_PRIORITY).

Not used when pushing data.

Scope
Display/Automated import process

pid

Type
string
Description
ID of the page where the imported records should be stored. Can be ignored and the general storage pid is used instead (see Configuration).
Scope
Store data

enforcePid

Type
boolean
Description

If this is set to true, all operations regarding existing records will be limited to records stored in the defined pid (i.e. either the above property or the general extension configuration). This has two consequences:

  1. when checking for existing records, those records will be selected only from the defined pid.
  2. when checking for records to delete, only records from the defined pid will be affected

This is a convenient way of protecting records from operations started from within the external import process, so that it won’t affect e.g. records created manually.

Scope
Store data

useColumnIndex

Type
string or integer
Description

In a basic configuration the same index must be used for the general TCA configuration and for each column configuration. With this property it is possible to use a different index for the column configurations. The “ctrl” part has to exist with its own index, but the columns may refer to another index and thus their configuration does not need to be defined. Obviously the index referred to must exist for columns.

The type may be a string or an integer, because a configuration key may also be either a string or an integer.

Scope
Configuration

customSteps

Type
array
Description

As explained in the process overview, the import process goes through several steps, depending on its type. This property makes it possible to register additional steps. Each step can be placed before or after any existing step (including previously registered custom steps).

The configuration is a simple array, each entry being itself an array with three properties:

  • class (required): name of the PHP class containing the custom step.
  • position (required): states when the new step should happen. The syntax for position is made of the keyword before or after, followed by a colon (:) and the name of an existing step class.
  • parameters (optional): array which is passed as is to the custom step class when it is called during the import process. Inside the step, it can be accessed using $this->parameters.

Example:

'customSteps' => [
        [
                'class' => \Cobweb\ExternalimportTest\Step\EnhanceDataStep::class,
                'position' => 'after:' . \Cobweb\ExternalImport\Step\ValidateDataStep::class
        ]
],

If any element of the custom step declaration is invalid, the step will be ignored. More information is given in the Developer’s Guide.

Scope
Any step

whereClause

Type
string
Description

SQL condition that will restrict the records considered during the import process. Only records matching the condition will be updated or deleted. This condition comes on top of the “enforcePid” condition, if defined.

Warning

This may cause many records to be inserted over time. Indeed if some external data is imported the first time, but then doesn’t match the whereClause condition, it will never be found for update. It will thus be inserted again and again. Whenever you make use of the whereClause property you should therefore watch for an unexpectedly high number of inserts.

Scope
Store data

additionalFields

Type
string
Description
This property is not part of the general configuration anymore. Please refer to the dedicated chapter.
Scope
Read data

updateSlugs

Type
boolean
Description
Slugs are populated automatically for new records thanks to External Import relying on the \TYPO3\CMS\Core\DataHandling\DataHandler class. The same is not true for updated records. If you want record slugs to be updated when modified external data is imported, set this flag to true.
Scope
Store data

namespaces

Type
array
Description

Associative array of namespaces that can be used in XPath queries. The keys correspond to prefixes and the values to URIs. The prefixes can then be used in XPath queries.

Example

Given the following declaration:

'namespaces' => array(
   'atom' => 'http://www.w3.org/2005/Atom'
)

a Xpath query like:

atom:link

could be used. The prefixes used for XPath queries don’t need to match the prefixes used in the actual XML source. The defaut namespace has to be registered too in order for XPath queries to succeed.

Scope
Handle data (XML)

description

Type
string
Description
A purely descriptive piece of text, which should help you remember what this particular synchronization is all about. Particularly useful when a table is synchronized with multiple sources.
Scope
Display

disabledOperations

Type
string
Description

Comma-separated list of operations that should not be performed. Possible operations are insert, update and delete. This way you can block any of these operations.

insert
The operation performed when new records are found in the external source.
update
Performed when a record already exists and only its data needs to be updated.
delete
Performed when a record is in the database, but is not found in the external source anymore.

See also the column-specific property disabledOperations.

Scope
Store data

minimumRecords

Type
integer
Description
Minimum number of items expected in the external data. If fewer items are present, the import is aborted. This can be used – for example – to protect the existing data against deletion when the fetching of the external data failed (in which case there are no items to import).
Scope
Validate data

disableLog

Type
integer
Description
Set to true to disable logging by the TYP3 Core Engine. This setting will override the general “Disable logging” setting (see Configuration for more details).
Scope
Store data

clearCache

Type
string
Description
Comma-separated list of caches identifiers for caches which should be cleared at the end of the import process. See Clearing the cache.
Scope
Clear cache