88use Psr \Http \Message \ServerRequestInterface ;
99use SFC \Staticfilecache \Event \CacheRuleEvent ;
1010use SFC \Staticfilecache \Event \ForceStaticFileCacheEvent ;
11- use TYPO3 \CMS \Frontend \Controller \TypoScriptFrontendController ;
11+ use TYPO3 \CMS \Core \TypoScript \FrontendTypoScript ;
12+ use TYPO3 \CMS \Frontend \Page \PageInformation ;
1213
1314/**
1415 * Force the cache for special pages.
@@ -19,33 +20,38 @@ public function __construct(protected readonly EventDispatcherInterface $eventDi
1920
2021 public function __invoke (CacheRuleEvent $ event ): void
2122 {
22- if ($ event ->isSkipProcessing () && $ this ->isForceCacheUri ($ GLOBALS [ ' TSFE ' ] ?? null , $ event ->getRequest ())) {
23+ if ($ event ->isSkipProcessing () && $ this ->isForceCacheUri ($ event ->getRequest ())) {
2324 $ event ->setSkipProcessing (false );
2425 $ event ->truncateExplanations ();
2526
26- if ($ GLOBALS ['TSFE ' ] instanceof TypoScriptFrontendController) {
27- if (!\is_array ($ GLOBALS ['TSFE ' ]->config ['INTincScript ' ])) {
27+ $ frontendTypoScript = $ event ->getRequest ()->getAttribute ('frontend.typoscript ' );
28+ if ($ frontendTypoScript instanceof FrontendTypoScript) {
29+ $ configArray = $ frontendTypoScript ->getConfigArray ();
30+ if (!\is_array ($ configArray ['INTincScript ' ])) {
2831 // Avoid exceptions in recursivelyReplaceIntPlaceholdersInContent
29- $ GLOBALS ['TSFE ' ]->config ['INTincScript ' ] = [];
32+ $ configArray ['INTincScript ' ] = [];
33+ $ frontendTypoScript ->setConfigArray ($ configArray );
3034 }
3135
36+ // @todo
3237 // render the plugins in the output
33- $ GLOBALS ['TSFE ' ]->INTincScript ($ event ->getRequest ());
38+ // v14??? $GLOBALS['TSFE']->INTincScript($event->getRequest());
3439 }
3540 }
3641 }
3742
3843 /**
3944 * Is force cache URI?
4045 */
41- protected function isForceCacheUri (? TypoScriptFrontendController $ frontendController , ServerRequestInterface $ request ): bool
46+ protected function isForceCacheUri (ServerRequestInterface $ request ): bool
4247 {
43- if (!\is_object ($ frontendController )) {
48+ $ pageInformation = $ request ->getAttribute ('frontend.page.information ' );
49+ if (!$ pageInformation instanceof PageInformation) {
4450 return false ;
4551 }
4652
47- $ forceStatic = (bool ) ($ frontendController -> page ['tx_staticfilecache_cache_force ' ] ?? false );
48- $ event = new ForceStaticFileCacheEvent ($ forceStatic , $ frontendController , $ request );
53+ $ forceStatic = (bool ) ($ pageInformation -> getPageRecord () ['tx_staticfilecache_cache_force ' ] ?? false );
54+ $ event = new ForceStaticFileCacheEvent ($ forceStatic , $ request );
4955 $ this ->eventDispatcher ->dispatch ($ event );
5056
5157 return $ event ->isForceStatic ();
0 commit comments