diff --git a/Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php b/Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php index ec7b5cb..c02ef03 100644 --- a/Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php +++ b/Classes/Hooks/Backend/Toolbar/ClearCacheActionsHook.php @@ -8,6 +8,7 @@ namespace KayStrobach\Dyncss\Hooks\Backend\Toolbar; use TYPO3\CMS\Backend\Toolbar\ClearCacheActionsHookInterface; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Backend\Routing\UriBuilder; @@ -26,10 +27,9 @@ class ClearCacheActionsHook implements ClearCacheActionsHookInterface public function manipulateCacheActions(&$cacheActions, &$optionValues) { $clearCacheSystemUser = (bool)($this->getBackendUser()->getTSConfig()['options.']['clearCache.']['system'] ?? false); - $isDevelopment = GeneralUtility::getApplicationContext()->isDevelopment(); - $clearCacheSystemSys = (bool)$GLOBALS['TYPO3_CONF_VARS']['SYS']['clearCacheSystem'] === true; + $isDevelopment = Environment::getContext()->isDevelopment(); $isAdmin = $this->getBackendUser()->isAdmin(); - if ($clearCacheSystemUser || $isDevelopment || ($clearCacheSystemSys && $isAdmin)) { + if ($clearCacheSystemUser || $isDevelopment || $isAdmin) { $uriBuilder = GeneralUtility::makeInstance(UriBuilder::class); $uriParameters = ['cacheCmd' => 'dyncss', 'ajaxCall' => 1]; $translationPrefix = 'LLL:EXT:dyncss/Resources/Private/Language/locallang.xlf:dyncss.toolbar.clearcache.'; @@ -53,5 +53,4 @@ protected function getBackendUser() { return $GLOBALS['BE_USER']; } - } diff --git a/Classes/Parser/AbstractParser.php b/Classes/Parser/AbstractParser.php index 1910cbc..71524df 100644 --- a/Classes/Parser/AbstractParser.php +++ b/Classes/Parser/AbstractParser.php @@ -2,10 +2,8 @@ namespace KayStrobach\Dyncss\Parser; -use KayStrobach\Dyncss\Utilities\ApplicationContext; use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Extbase\Utility\ArrayUtility; /** * @todo fix type hinting in @param comments @@ -38,6 +36,9 @@ abstract class AbstractParser implements ParserInterface * @var array */ protected $config = []; + protected $cacheFilename = ''; + protected $inputFilename = ''; + protected $outputFilename = ''; /** * @var \TYPO3\CMS\Extbase\SignalSlot\Dispatcher @@ -59,7 +60,7 @@ public function __construct() */ protected function initEmConfiguration() { - $this->config = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['dyncss']); + $this->config = $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['dyncss'] ?? []; } /** @@ -292,13 +293,15 @@ public function compileFile($inputFilename, $outputFilename = null) $this->outputFilename = $outputFilename; $this->cacheFilename = $cacheFilename; + $applicationContext = Environment::getContext(); + // exit if a precompiled version already exists - if ((file_exists($outputFilename)) && (!ApplicationContext::isDevelopmentModeActive() && (!$this->config['enableDebugMode']))) { + if ((file_exists($outputFilename)) && (!$applicationContext->isDevelopment() && (!$this->config['enableDebugMode']))) { return $outputFilename; } //write intermediate file, if the source has been changed, the rest is done by the cache management - if (@filemtime($outputFilename) < @filemtime($inputFilename) || $this->_checkIfCompileNeeded($inputFilename) || ApplicationContext::isDevelopmentModeActive()) { + if (@filemtime($outputFilename) < @filemtime($inputFilename) || $this->_checkIfCompileNeeded($inputFilename) || $applicationContext->isDevelopment()) { file_put_contents($preparedFilename, $this->_prepareCompile(file_get_contents($inputFilename))); $fileContent = $this->_postCompile($this->_compileFile($inputFilename, $preparedFilename, $outputFilename, $cacheFilename)); @@ -339,5 +342,4 @@ public function prepareEnvironment($fname) } return true; } - } diff --git a/Classes/Utilities/ApplicationContext.php b/Classes/Utilities/ApplicationContext.php deleted file mode 100644 index c34f576..0000000 --- a/Classes/Utilities/ApplicationContext.php +++ /dev/null @@ -1,82 +0,0 @@ -featureManager = $objectManager->get('TYPO3\CMS\Install\Configuration\FeatureManager'); - } - - /** - * @return bool - */ - public static function isDevelopmentModeActive() - { - $applicationContext = new self(); - - return $applicationContext->isDevelopmentApplicationContext() || $applicationContext->isDevelopPresetActive(); - } - - /** - * @return bool - */ - public function isDevelopmentApplicationContext() - { - if (GeneralUtility::getApplicationContext()->isDevelopment()) { - return true; - } - - return false; - } - - /** - * @throws \TYPO3\CMS\Install\Configuration\Exception - * - * @return null|\TYPO3\CMS\Install\Configuration\AbstractPreset - */ - public function isDevelopPresetActive() - { - $features = $this->featureManager->getInitializedFeatures([]); - /* @var \TYPO3\CMS\Install\Configuration\Context\ContextFeature $contextPreset */ - $contextFeature = null; - foreach ($features as $feature) { - if ($feature instanceof \TYPO3\CMS\Install\Configuration\Context\ContextFeature) { - $contextFeature = $feature; - continue; - } - } - if ($contextFeature === null) { - return; - } - $activePreset = null; - $presets = $contextFeature->getPresetsOrderedByPriority(); - foreach ($presets as $preset) { - /** @var \TYPO3\CMS\Install\Configuration\AbstractPreset $preset */ - if ($preset->isActive()) { - $activePreset = $preset; - continue; - } - } - if ($activePreset && $activePreset->getName() === 'Development') { - return true; - } - - return false; - } -} diff --git a/ext_emconf.php b/ext_emconf.php index 9ff2bf6..322b04e 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -34,7 +34,7 @@ 'CGLcompliance_note' => '', 'constraints' => [ 'depends' => [ - 'typo3' => '9.5.00-10.4.99', + 'typo3' => '9.5.00-11.5.99', ], 'conflicts' => [ ], diff --git a/ext_localconf.php b/ext_localconf.php index 56ed9bf..c4d3f73 100644 --- a/ext_localconf.php +++ b/ext_localconf.php @@ -26,7 +26,7 @@ /** * @author Kay Strobach */ -if (!defined('TYPO3_MODE')) { +if (!defined('TYPO3')) { die('Access denied.'); } //if(TYPO3_MODE === 'BE') { diff --git a/ext_tables.php b/ext_tables.php index 50913eb..9fe290d 100644 --- a/ext_tables.php +++ b/ext_tables.php @@ -1,22 +1,18 @@ 'actions-system-cache-clear-dyncss.svg' - ]; - $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); - foreach ($iconsSvg as $identifier => $path) { - $iconRegistry->registerIcon( - $identifier, - \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, - ['source' => 'EXT:' . $extKey . '/Resources/Public/Icons/' . $path] - ); - } +defined('TYPO3') || die('Access denied.'); +call_user_func(function() { + // Add/register icons + // register svg icons: identifier and filename + $iconsSvg = [ + 'actions-system-cache-clear-dyncss' => 'actions-system-cache-clear-dyncss.svg' + ]; + $iconRegistry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Imaging\IconRegistry::class); + foreach ($iconsSvg as $identifier => $path) { + $iconRegistry->registerIcon( + $identifier, + \TYPO3\CMS\Core\Imaging\IconProvider\SvgIconProvider::class, + ['source' => 'EXT:dyncss/Resources/Public/Icons/' . $path] + ); } - }, - 'dyncss' + } );