I'm trying to run DataHandler commands from multiple contexts (Frontend, Backend, etc.). From what I've read and tried, this has to be done within a Synfony command for it to work properly. Only then, within the command, code snippets like these can be run:
Bootstrap::initializeBackendAuthentication();
$data = [...]
$dataHandler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\DataHandling\DataHandler::class);
$dataHandler->start($data, []);
$dataHandler->process_datamap();
And it's the _cli_
back-end user the one running these DataHandler commands.
I've created my Synfony command according to the docs. It's registered and I can call it like this and it works as expected:
$ vendor/bin/typo3 myext:rundatahandler
My question is: How can I run this within a PHP class? I can't find it anywere in the docs or online. I only find it for Synfony Controller classes, which behave differently and have different inputs and attributes than those of TYPO3.
Thanks a lot in advance!