DataSourceAwareProcessor 

Implement the \CPSIT\Typo3Handlebars\DataProcessing\DataSource\DataSourceAwareProcessor interface to run custom PHP logic during the preProcessing or postProcessing stages of a process-variables processor (or of HANDLEBARSTEMPLATE directly). Unlike standard TYPO3 data processors, implementations receive a DataSourceCollection that gives structured access to all four data sources available at that point in the pipeline.

interface DataSourceAwareProcessor
Fully qualified name
\CPSIT\Typo3Handlebars\DataProcessing\DataSource\DataSourceAwareProcessor
process ( array $variables, DataSourceCollection $collection, ContentObjectRenderer $contentObjectRenderer)

Process the current variable set and return the (modified) array.

param array $variables

Current template variable set.

param DataSourceCollection $collection

All four data sources for the current rendering.

param ContentObjectRenderer $contentObjectRenderer

Current content element renderer.

returntype

array

Reading from DataSourceCollection 

DataSourceCollection::resolve() searches the data sources in priority order and returns the first match. Pass a specific DataSource case to restrict the lookup:

use CPSIT\Typo3Handlebars\DataProcessing\DataSource\DataSource;

// Search all sources (highest priority first)
$table = $collection->resolve('table');

// Search only the processor configuration
$table = $collection->resolve('table', DataSource::ProcessorConfiguration);

// Search two specific sources, in the given order
$table = $collection->resolve('table', [
    DataSource::ProcessorConfiguration,
    DataSource::ContentObjectConfiguration,
]);
Copied!

The four DataSource cases are:

  • DataSource::ProcessorConfiguration — this processor's own config block
  • DataSource::ProcessedData — accumulated output from previous processors
  • DataSource::ContentObjectRenderer — current record's field values
  • DataSource::ContentObjectConfiguration — top-level HANDLEBARSTEMPLATE config

Example implementation 

EXT:my_extension/Classes/DataProcessing/MyPreProcessor.php
namespace Vendor\Extension\DataProcessing;

use CPSIT\Typo3Handlebars\DataProcessing\DataSource\DataSource;
use CPSIT\Typo3Handlebars\DataProcessing\DataSource\DataSourceAwareProcessor;
use CPSIT\Typo3Handlebars\DataProcessing\DataSource\DataSourceCollection;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

final readonly class MyPreProcessor implements DataSourceAwareProcessor
{
    public function process(
        array $variables,
        DataSourceCollection $collection,
        ContentObjectRenderer $contentObjectRenderer,
    ): array {
        $table = $collection->resolve('table', DataSource::ProcessorConfiguration, 'tt_content');
        $variables['tableName'] = $table;

        return $variables;
    }
}
Copied!

Registering the processor 

Reference the processor class by its fully qualified class name in preProcessing or postProcessing:

10 = process-variables
10 {
    variables {
        header = TEXT
        header.field = header
    }

    preProcessing {
        10 = Vendor\Extension\DataProcessing\MyPreProcessor
    }
}
Copied!

The numeric keys control execution order when multiple processors are registered. The class is instantiated via GeneralUtility::makeInstance(), so constructor injection works as normal.