Skip to content

Commit

Permalink
[TASK] Mitigate removed TSFE->getContext() method in `RenderTransla…
Browse files Browse the repository at this point in the history
…tedFlagInFrontendPreviewMode`

TYPO3 removed quite some method of `TSFE` internal or removed them,
one of them `getContext()` can be mitigated easily.

This change retrieves the context either from TSFE or uses the
`GeneralUtility::makeInstance()` to retrieve it within the
`RenderTranslatedFlagInFrontendPreviewMode` PSR-14 event listener.
  • Loading branch information
sbuerk committed Dec 19, 2024
1 parent 7bee314 commit caa7b81
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace WebVision\Deepltranslate\Core\Event\Listener;

use TYPO3\CMS\Core\Context\Context;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Frontend\Event\AfterCacheableContentIsGeneratedEvent;

Expand All @@ -18,7 +20,9 @@ final class RenderTranslatedFlagInFrontendPreviewMode
public function __invoke(AfterCacheableContentIsGeneratedEvent $event): void
{
$controller = $this->getTypoScriptFrontendController($event);
$context = $controller->getContext();
$context = ((new Typo3Version())->getMajorVersion() >= 13)
? GeneralUtility::makeInstance(Context::class)
: $controller->getContext();
if (
!$this->isInPreviewMode($context)
|| $this->processWorkspacePreview($context)
Expand Down

0 comments on commit caa7b81

Please sign in to comment.