简体   繁体   中英

How to use DataProcessors with TYPO3 plugins

The way to add a DataProcessor to a PAGE or a FLUIDTEMPLATE is often shown. How can it be assigned to a TYPO3 plugin?

For a PAGE you can do it like this:

page {
    10 {
        dataProcessing {
            1558428437 = BK2K\BootstrapPackage\DataProcessing\ConstantsProcessor
            1558428437 {
                as = myconstants
                key = settings.constants
            }
        }
   }
}

But can you do something like this:

config.tx_extbase {
    dataProcessing {
        1558428437 = BK2K\BootstrapPackage\DataProcessing\ConstantsProcessor
        1558428437 {
            as = myconstants
            key = settings.constants
        }
    }

Many thanks!

No, this is not possible since data processors is a feature of the FLUIDTEMPLATE content object alone.

In this case you can invoke the ConstantsProcessor manually in your controller action. You can get the current ContentObjectRenderer via $this->configurationManager->getContentObject() . The $processorConfiguration is the same as in TypoScript but as array:

$constantsProcessor = GeneralUtility::makeInstance(ConstantsProcessor::class);
$data = $constantsProcessor->process(
    $this->configurationManager->getContentObject(),
    [],
    [
        'key' => 'settings.constants',
        'as' => 'myconstants',
    ],
    []
);

// Use $data['myconstants']

That's currently not possible.

This would definitely be a feature that would make live of Integrators much easier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM