|
|
@@ -2,15 +2,16 @@
|
|
|
|
|
|
namespace Opentalent\OtTemplating\Utility;
|
|
|
|
|
|
+use Opentalent\OtTemplating\Page\OtPageRepository;
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
use RuntimeException;
|
|
|
-use TYPO3\CMS\Core\DataHandling\DataHandler;
|
|
|
use TYPO3\CMS\Core\Service\OpcodeCacheService;
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
|
|
use TYPO3\CMS\Install\Service\ClearCacheService;
|
|
|
use TYPO3\CMS\Install\Service\Typo3tempFileService;
|
|
|
+use TYPO3\CMS\Core\Cache\CacheManager;
|
|
|
|
|
|
-class CacheManager
|
|
|
+class OtCacheManager
|
|
|
{
|
|
|
|
|
|
/**
|
|
|
@@ -19,9 +20,11 @@ class CacheManager
|
|
|
* @param int $pageUid
|
|
|
*/
|
|
|
public static function clearPageCache(int $pageUid) {
|
|
|
- $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
|
|
|
- $dataHandler->start([], []);
|
|
|
- $dataHandler->clear_cacheCmd($pageUid);
|
|
|
+ $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
|
|
|
+ $cacheManager->flushCachesInGroupByTag(
|
|
|
+ 'pages',
|
|
|
+ 'pageId_' . $pageUid
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -31,17 +34,17 @@ class CacheManager
|
|
|
*/
|
|
|
public static function clearSiteCache(int $pageUid) {
|
|
|
|
|
|
- $pageRepository = new \Opentalent\OtTemplating\Page\OtPageRepository();
|
|
|
+ $pageRepository = new OtPageRepository();
|
|
|
$rootPage = $pageRepository->getRootPageFor($pageUid);
|
|
|
$pages = $pageRepository->getAllSubpagesForPage($rootPage['uid']);
|
|
|
+ $pages[] = $rootPage;
|
|
|
|
|
|
- $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
|
|
|
- $dataHandler->start([], []);
|
|
|
-
|
|
|
- foreach ($pages as $page) {
|
|
|
- $dataHandler->clear_cacheCmd($page['uid']);
|
|
|
- }
|
|
|
+ $cacheManager = GeneralUtility::makeInstance(CacheManager::class);
|
|
|
|
|
|
+ $tags = array_map(function ($page) {
|
|
|
+ return 'pageId_' . $page['uid'];
|
|
|
+ }, $pages);
|
|
|
+ $cacheManager->flushCachesInGroupByTags('pages', $tags);
|
|
|
}
|
|
|
|
|
|
/**
|