‪TYPO3CMS  ‪main
CachingFrameworkGarbageCollectionTask.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
20 
30 {
37  public ‪$selectedBackends = [];
38 
44  public function ‪execute()
45  {
46  // Global sub-array with all configured caches
47  $cacheConfigurations = ‪$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] ?? null;
48  if (is_array($cacheConfigurations)) {
49  // Iterate through configured caches and call garbage collection if
50  // backend is within selected backends in additional field of task
51  foreach ($cacheConfigurations as $cacheName => $cacheConfiguration) {
52  // The cache backend used for this cache
53  $usedCacheBackend = $cacheConfiguration['backend'] ?? null;
54  if (in_array($usedCacheBackend, $this->selectedBackends)) {
55  GeneralUtility::makeInstance(CacheManager::class)->getCache($cacheName)->collectGarbage();
56  }
57  }
58  }
59  return true;
60  }
61 }
‪TYPO3\CMS\Scheduler\Task
Definition: AbstractTask.php:16
‪TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask
Definition: CachingFrameworkGarbageCollectionTask.php:30
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:33
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:36
‪TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask\execute
‪bool execute()
Definition: CachingFrameworkGarbageCollectionTask.php:43
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Scheduler\Task\CachingFrameworkGarbageCollectionTask\$selectedBackends
‪array $selectedBackends
Definition: CachingFrameworkGarbageCollectionTask.php:36
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52