Wiki

Clone wiki

t3lephant / Data provider and dumps

Data provider and dumps

t3lephant is a data provider. Data, stored in files, will be synced with database. This article describes how to register dumps.

Register provider and dumps

The place where you register and configure t3lephant's data provider is: typo3conf/AdditionalConfiguration.php. Just add this:

if (!class_exists('ArminVieweg\T3lephant\Provider\Factory\DataProviderFactory')) {
    require_once(PATH_typo3conf . 'ext/t3lephant/Classes/Provider/Factory/DataProviderFactory.php');
}

$jsonDataProvider = DataProviderFactory::create(DataProviderFactory::JSON_PROVIDER);
$jsonDataProvider->addDumpDirectory(PATH_typo3conf . 'Environments/Dev/Dumps/', true);

Because AdditionalConfiguration.php is involved very early in bootstrap process of TYPO3 we need to check if the DataProviderFactory class exists and if not include it. There are more files required than the DataProviderFactory, but these dependecies are solved by the factory.

Then we define which provider we want to use. Currently t3lephant provides only a JsonDataProvider, but you can write your own provider.

And we tell t3lephant where it finds the dumps which contains the data. In this example I've referenced a folder (recursivly), but you can also reference single files.

Methods

The following two methods are defined in DataProviderInterface to register dumps and they are available for all data providers used by t3lephant.

DataProviderInterface::addDumpDirectory($direcotryName, $recursive)

Example:

$jsonDataProvider->addDumpDirectory(PATH_typo3conf . 'Environments/Dev/Dumps/', true);

Parameter Type Default Description
$direcotryName string - Absolute path to directory, with adherent slash.
$recursive bool false Also load dumps from subdirectories.

DataProviderInterface::addDumpFile($fileName, $tableName)

Example:

$jsonDataProvider->addDumpFile(PATH_typo3conf . 'Environments/Dev/Dumps/file.json', 'sys_template');

Parameter Type Default Description
$fileName string - Absolute path to dump file.
$tableName string/null null Specifies the table name for which the dump is existing for. When set to null the tableName is taken from filename (without file extension).

Cache notice

Changes in AdditionalConfiguration.php requires to clear the System Cache of TYPO3.

2015-11-18_1356.png

This does not affect the dump files itself. When you've specified a directory as source, you can add and modify dumps without need to clear any caches.


« Back to overview

Updated