Commit 4fb3e933 authored by Matthias Adrowski's avatar Matthias Adrowski
Browse files

[TASK] Fix possble php8.1 errors

parent c8fd16d5
......@@ -31,6 +31,9 @@ use TYPO3\CMS\Fluid\View\StandaloneView;
*
*/
class PreviewRenderer implements PreviewRendererInterface {
public const RETURNTYPE_ARR = 'array';
/**
* @var LanguageService $languageService
*/
......@@ -82,7 +85,7 @@ class PreviewRenderer implements PreviewRendererInterface {
'T3DataStructure'
)['data']['sDEF']['lDEF'];
$tabElements = GeneralUtility::trimExplode(',', $pluginConfiguration['data']['vDEF'], TRUE);
$tabElements = GeneralUtility::trimExplode(',', $this->passVDefOnKeyToTemplate($pluginConfiguration, 'data'), TRUE);
$tabs = [];
foreach ($tabElements as $tabElement) {
......@@ -108,7 +111,7 @@ class PreviewRenderer implements PreviewRendererInterface {
];
}
$titles = GeneralUtility::trimExplode("\n", $pluginConfiguration['titles']['vDEF']);
$titles = GeneralUtility::trimExplode("\n",$this->passVDefOnKeyToTemplate($pluginConfiguration, 'titles'));
// Remove first item if it is empty to mimic what is actually saved to the DB and frontend behaviour.
// This gets done automatically on a second save of the plugin anyways but it should happen every time.
if ($titles[0] === '') {
......@@ -116,19 +119,38 @@ class PreviewRenderer implements PreviewRendererInterface {
}
$templateData = [
'mode' => $pluginConfiguration['mode']['vDEF'],
'mode' => $this->passVDefOnKeyToTemplate($pluginConfiguration, 'mode'),
'tabs' => $tabs,
'titles' => $titles,
'enableAutoPlay' => $pluginConfiguration['enableAutoPlay']['vDEF'],
'autoPlayInterval' => $pluginConfiguration['autoPlayInterval']['vDEF'],
'enableMouseOver' => $pluginConfiguration['enableMouseOver']['vDEF'],
'hashName' => $pluginConfiguration['hashName']['vDEF']
'enableAutoPlay' => $this->passVDefOnKeyToTemplate($pluginConfiguration, 'enableAutoPlay'),
'autoPlayInterval' => $this->passVDefOnKeyToTemplate($pluginConfiguration, 'autoPlayInterval'),
'enableMouseOver' => $this->passVDefOnKeyToTemplate($pluginConfiguration, 'enableMouseOver'),
'hashName' => $this->passVDefOnKeyToTemplate($pluginConfiguration, 'hashName')
];
$view->assign('data', $templateData);
return $view->render();
}
/**
* @param array $conf
* @param string $key
* @param string $returnType
* @return array|mixed|string
*/
private function passVDefOnKeyToTemplate(array $conf, string $key, string $returnType = '') {
if(isset($conf[$key])) {
return $conf[$key]['vDEF'];
}
// check if we got a possible returntype:
if($returnType === self::RETURNTYPE_ARR) {
return [];
}
return '';
}
/**
* Render a footer for the record to display in page module below
* the body of the item's preview.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment