[TYPO3-english] Extbase/Fluid extension: clear caches for all pages containing a plugin on records data update?

Hagen Gebauer gebauer at mpi-cbg.de
Tue Mar 31 14:21:28 CEST 2015


Hi everybody,

I am looking for a way to automatically clear the caches of all pages containing a plugin of my calendar extension every time I update the calendar data records. I tried to implement what I think does the job in tx_news, but it does not work. I must have missed something obviously.

/mycalendar/ext_localconf.php:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['clearCachePostProc'][$_EXTKEY.'_clearcache'] =
'Vendor\Mycalendar\Utility\Tcemain->clearCachePostProc';

/mycalendar/Classes/Utility/Tcemain.php:
<?php
namespace Vendor\Mycalendar\Utility\;

class Tcemain {
	/**
	 * Flushes the cache if a calendar record was edited.
	 *
	 * @param array $params
	 * @return void
	 */
	public function clearCachePostProc(array $params) {
		if(isset($params['table']) && isset($params['uid'])) {
			$cacheTag = $params['table'].'_'.$params['uid'];

			/** @var $cacheManager \TYPO3\CMS\Core\Cache\CacheManager */
			$cacheManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Cache\\CacheManager');
			$cacheManager->getCache('cache_pages')->flushByTag($cacheTag);
			$cacheManager->getCache('cache_pagesection')->flushByTag($cacheTag);
			$cacheManager->getCache('cache_pages')->flushByTag('tx_mycalendar');
			$cacheManager->getCache('cache_pagesection')->flushByTag('tx_mycalendar');
		}
	}
}
?>

The class method is being called, it obviously also gets the $params array correctly (if I put a php error somewhere into the method it gets reported).

Thanks a lot in advance!

Cheers,
Hagen.


More information about the TYPO3-english mailing list