Skip to content

Commit

Permalink
#156 Code checkup for TYPO3 v12 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
DirkPersky committed Oct 31, 2024
1 parent 4ebb5ce commit 43187b5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 17 deletions.
58 changes: 42 additions & 16 deletions Classes/Middleware/PlainRenderingMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use TYPO3\CMS\Core\TypoScript\AST\Node\RootNode;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Database\ConnectionPool;
use TYPO3\CMS\Core\Information\Typo3Version;

class PlainRenderingMiddleware implements MiddlewareInterface
{
Expand All @@ -32,31 +33,56 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
return $handler->handle($request);
}

// get frontend typoscript
$frontendTyposcript = $request->getAttribute('frontend.typoscript');

$configArray = $frontendTyposcript->getConfigArray();
$configArray['debug'] = 0;
$configArray['disableAllHeaderCode'] = 1;
$configArray['disableCharsetHeader'] = 0;
$frontendTyposcript->setConfigArray($configArray);

// prepare rendering overwrite
// set UID
$uid = $request->getQueryParams()[self::namespace]['content'];

$pageArray = $frontendTyposcript->getPageArray();
$pageArray['10'] = 'COA';
$pageArray['10.'] = [
'10' => 'RECORDS',
// get current typo3 version
$version = GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion();
// prepare page rendering
$pageArray = [
'10' => 'COA',
'10.' => [
'tables' => 'tt_content',
'source' => "tt_content_{$uid}"
'10' => 'RECORDS',
'10.' => [
'tables' => 'tt_content',
'source' => "tt_content_{$uid}"
]
]
];
$frontendTyposcript->setPageArray($pageArray);
// get frontend typoscript
$setup = $frontendTyposcript->getSetupArray();
// change fluid Layout to remove Wrap
if (isset($setup['lib.']['contentElement.'])) $setup['lib.']['contentElement.']['layoutRootPaths.'][999] = 'EXT:dp_cookieconsent/Resources/Private/Overwrite/Layouts/';
// TODO Check: Working T3 v 13?
if ($version >= 13) {
$configArray = $frontendTyposcript->getConfigArray();
$configArray = array_merge($configArray, [
'debug' => 0,
'disableAllHeaderCode' => 1,
'disableCharsetHeader' => 0
]);
// disable svgstore
if (isset($configArray['svgstore.'])) $configArray['svgstore.']['enabled'] = 0;
$frontendTyposcript->setSetupArray($setup);
$frontendTyposcript->setConfigArray($configArray);
$frontendTyposcript->setPageArray($pageArray);
} else {
// fallback to older TYPO3 versions
$setup['config.'] = array_merge($setup['config.'], [
'debug' => 0,
'disableAllHeaderCode' => 1,
'disableCharsetHeader' => 0
]);
// disable svgstore
if (isset($setup['config.']['svgstore.'])) $setup['config.']['svgstore.']['enabled'] = 0;
// set TypoScript updates
$frontendTyposcript->setSetupArray($setup);
$controller->pSetup = $pageArray;
}

$request = $request->withAttribute('frontend.typoscript', $frontendTyposcript);

return $handler->handle($request);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"AGPL-3.0-or-later"
],
"require": {
"typo3/cms-core": "^10.4.0||^11.5.0||^12.4.0||^13.4.0||dev-master||dev-main"
"typo3/cms-core": "^12.4.0||^13.4.0||dev-main"
},
"replace": {
"typo3-ter/dp_cookieconsent": "self.version"
Expand Down

0 comments on commit 43187b5

Please sign in to comment.