Skip to content

Commit

Permalink
Merge pull request #409 from peterkraume/v13
Browse files Browse the repository at this point in the history
[TASK] Use context API instead of TSFE
  • Loading branch information
lochmueller committed Mar 18, 2024
2 parents 0075628 + 5580e56 commit 597f083
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 597f083

Please sign in to comment.