Skip to content

Commit

Permalink
[TASK] Use context API instead of TSFE
Browse files Browse the repository at this point in the history
In TYPO3 v13 `TypoScriptFrontendController->getContext()` has been
marked as @internal`.
  • Loading branch information
peterkraume committed Mar 17, 2024
1 parent 0075628 commit 5580e56
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Classes/Cache/Rule/NoWorkspacePreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@
namespace SFC\Staticfilecache\Cache\Rule;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
use TYPO3\CMS\Core\Context\Context;

/**
* No workspace preview.
*/
class NoWorkspacePreview extends AbstractRule
{
public function __construct(
private readonly Context $context,
)
{
}

/**
* Check if it is no workspace preview.
*/
public function checkRule(ServerRequestInterface $request, array &$explanation, bool &$skipProcessing): void
{
$tsfe = $GLOBALS['TSFE'] ?? null;
if ($tsfe instanceof TypoScriptFrontendController && $tsfe->getContext()->getPropertyFromAspect('workspace', 'isOffline', false)) {
if ($this->context->getPropertyFromAspect('workspace', 'isOffline', false)) {
$explanation[__CLASS__] = 'The page is in workspace preview mode';
}
}
Expand Down

0 comments on commit 5580e56

Please sign in to comment.