diff --git a/Classes/Cache/CacheFactory.php b/Classes/Cache/CacheFactory.php index 9ce587f..c792913 100644 --- a/Classes/Cache/CacheFactory.php +++ b/Classes/Cache/CacheFactory.php @@ -15,6 +15,7 @@ namespace Evoweb\Extender\Cache; +use Evoweb\Extender\Hooks\ClearCacheHook; use TYPO3\CMS\Core\Cache\Backend\AbstractBackend; use TYPO3\CMS\Core\Cache\Backend\FileBackend; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; @@ -52,5 +53,7 @@ public function createCache(string $identifier): ?FrontendInterface public static function addClassCacheConfigToGlobalTypo3ConfVars(): void { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extender'] = static::$configuration; + $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc']['extender'] = + ClearCacheHook::class . '->'; } } diff --git a/Classes/Hooks/ClearCacheHook.php b/Classes/Hooks/ClearCacheHook.php new file mode 100644 index 0000000..ab19b7a --- /dev/null +++ b/Classes/Hooks/ClearCacheHook.php @@ -0,0 +1,23 @@ + $parameters + */ + public function clearCachePostProc(array $parameters): void + { + if (Environment::getContext()->isDevelopment() && $parameters['cacheCmd'] === 'all') { + $this->classCache->flush(); + } + } +} diff --git a/Classes/Loader/ClassLoader.php b/Classes/Loader/ClassLoader.php index a5c38f1..dd91d00 100644 --- a/Classes/Loader/ClassLoader.php +++ b/Classes/Loader/ClassLoader.php @@ -17,8 +17,6 @@ use Evoweb\Extender\Cache\ClassCacheManager; use Evoweb\Extender\Configuration\ClassRegister; -use Symfony\Component\DependencyInjection\Attribute\Autowire; -use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Cache\Frontend\PhpFrontend; use TYPO3\CMS\Core\SingletonInterface; diff --git a/Configuration/Services.yaml b/Configuration/Services.yaml index 3da1679..0ce9144 100644 --- a/Configuration/Services.yaml +++ b/Configuration/Services.yaml @@ -44,6 +44,11 @@ services: $container: '@service_container' shared: false + Evoweb\Extender\Hooks\ClearCacheHook: + public: true + arguments: + $classCache: '@cache.extender' + Evoweb\Extender\Loader\ClassLoader: arguments: $classCache: '@cache.extender'