-
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature - disable StaticFileCache by site configuration for TYPO3 V9
- Loading branch information
1 parent
0d789bf
commit 0d1f64d
Showing
3 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
/** | ||
* Check if the current site is static cacheable. | ||
*/ | ||
|
||
declare(strict_types = 1); | ||
|
||
namespace SFC\Staticfilecache\Cache\Rule; | ||
|
||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | ||
|
||
/** | ||
* Check if the current site is static cacheable. | ||
*/ | ||
class SiteCacheable extends AbstractRule | ||
{ | ||
/** | ||
* Check if the current site is static cacheable. | ||
* | ||
* @param TypoScriptFrontendController $frontendController | ||
* @param string $uri | ||
* @param array $explanation | ||
* @param bool $skipProcessing | ||
*/ | ||
public function checkRule(TypoScriptFrontendController $frontendController, string $uri, array &$explanation, bool &$skipProcessing) | ||
{ | ||
if (!($GLOBALS['TYPO3_REQUEST'] instanceof \TYPO3\CMS\Core\Http\ServerRequest)) { | ||
return; | ||
} | ||
$site = $GLOBALS['TYPO3_REQUEST']->getAttribute('site'); | ||
if (!($site instanceof \TYPO3\CMS\Core\Site\Entity\Site)) { | ||
return; | ||
} | ||
$config = $site->getConfiguration(); | ||
if (isset($config['disableStaticFileCache']) && $config['disableStaticFileCache']) { | ||
$explanation[__CLASS__] = 'static cache disabled on site configuration: ' . $site->getIdentifier(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
$GLOBALS['SiteConfiguration']['site']['columns']['disableStaticFileCache'] = [ | ||
'label' => 'Disable StaticFileCache', | ||
'config' => [ | ||
'type' => 'check', | ||
], | ||
]; | ||
|
||
$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] = str_replace( | ||
'base,', | ||
'base, disableStaticFileCache, ', | ||
$GLOBALS['SiteConfiguration']['site']['types']['0']['showitem'] | ||
); |