Skip to content

Commit fdb7112

Browse files
committed
[BUGFIX] Determine preview mode for v9
As the Context is introduced in v10 to TypoScriptFrontendController and therefore PreviewAspect cannot be determined, in v9 the preview mode is checked in a different way. This bugfix respects the non-existing Context and PreviewAspect in TYPO v9 to determine the correct behaviour in the renderDeeplPreviewFlag
1 parent e3947f5 commit fdb7112

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Classes/Hooks/DeeplPreviewFlagGeneratePageHook.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace WebVision\WvDeepltranslate\Hooks;
66

7+
use TYPO3\CMS\Core\Information\Typo3Version;
8+
use TYPO3\CMS\Core\Utility\GeneralUtility;
79
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
810

911
class DeeplPreviewFlagGeneratePageHook
@@ -15,8 +17,13 @@ public function renderDeeplPreviewFlag(array $params): void
1517
{
1618
$controller = $params['pObj'];
1719

18-
$isInPreviewMode = $controller->getContext()->hasAspect('frontend.preview')
19-
&& $controller->getContext()->getPropertyFromAspect('frontend.preview', 'isPreview');
20+
$typo3Version = GeneralUtility::makeInstance(Typo3Version::class);
21+
if ($typo3Version->getMajorVersion() < 10) {
22+
$isInPreviewMode = (bool)$controller->fePreview;
23+
} else {
24+
$isInPreviewMode = $controller->getContext()->hasAspect('frontend.preview')
25+
&& $controller->getContext()->getPropertyFromAspect('frontend.preview', 'isPreview');
26+
}
2027
if (
2128
!$isInPreviewMode
2229
|| $controller->doWorkspacePreview()

0 commit comments

Comments
 (0)