1. Go to this page and download the library: Download bnf/typo3-middleware library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bnf / typo3-middleware example snippets
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Bnf\SlimTypo3\AppRegistry::class)
->push(function($app) {
$pimple = $app->getContainer()->get('pimple');
$pimple['objectManager'] = function ($c) {
return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
};
$pimple['whateverRepository'] = function ($c) {
return $c['objectManager']->get(\Vendor\Extension\Domain\Repository\WhateverRepository::class);
};
$pimple['exportService'] = function ($c) {
return $c['objectManager']->get(\Vendor\Extension\Service\ExportService::class);
};
$app->get('/export-whatever[/]', function ($request, $response) {
$objects = $this->get('whateverRepository')->findAll();
$xml = $this->get('exportService')->whateverToXml($objects);
$response->getBody()->write($xml->saveXML());
return $response;
})->add(new \Bnf\Typo3Middleware\ExtbaseMiddleware([
'persistence' => [
'storagePid' => 78,
/* TypoScript is not evaluated (by design), you need to provide _all_
*
\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Bnf\SlimTypo3\AppRegistry::class)
->push(function($app) {
/* Simple Example, no (content element) context, only call extbase plugin */
$app->get('/some-extbase-api', function ($request, $response) {
$handler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Bnf\Typo3Middleware\TypoScriptRenderingMiddleware::class, [
'signature' => 'extensionname_pluginname',
]);
return $handler->process($request);
});
/* Execute the same plugin as above (now specified using 'extension' and 'plugin')
* in the context of page '213' and with flexform settings from tt_content record '3284'.
* Also (optionally) pass the argument 'foo' to the extbase controller.
*/
$app->get('/some-custom-extbase-action[/{foo}]', function ($request, $response, $args) {
$handler = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\Bnf\Typo3Middleware\TypoScriptRenderingMiddleware::class, [
'extension' => 'VendorName.ExtensionName',
'plugin' => 'PluginName',
'page' => '213',
'record' => 'tt_content_3284',
'arguments' => [
'foo' => $args['foo'] ?? null,
],
'page' => '649',
]);
/* Add a custom header to the request, that's returned by extbase/TYPO3 core */
return $handler->process($request)->withHeader('Content-Type', 'application/xml');
});
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.