‪TYPO3CMS  9.5
SiteDataHandlerCacheHook.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
24 
32 {
42  public function ‪processDatamap_afterDatabaseOperations(string $status, string $table, $recordId, array $updatedFields, ‪DataHandler $dataHandler)
43  {
44  if ($table === 'sys_domain'
45  || $table === 'sys_language'
46  || ($status === 'new' && $table === 'pages' && (int)$updatedFields['pid'] === 0)
47  ) {
48  $this->‪getCache()->‪remove('pseudo-sites');
49  $this->‪getCache()->‪remove('legacy-domains');
50  // After evicting caches, we need to make sure these are re-initialized within the
51  // current request if needed. Easiest solution is to purge the SiteMatcher singleton.
52  GeneralUtility::removeSingletonInstance(SiteMatcher::class, GeneralUtility::makeInstance(SiteMatcher::class));
53  }
54  }
55 
67  public function ‪processCmdmap_postProcess(string $command, string $table, $id, $value, ‪DataHandler $dataHandler, $pasteUpdate, array $pasteDatamap)
68  {
69  if ($table === 'sys_domain' || $table === 'sys_language') {
70  $this->‪getCache()->‪remove('pseudo-sites');
71  $this->‪getCache()->‪remove('legacy-domains');
72  }
73  }
74 
80  protected function ‪getCache(): ‪FrontendInterface
81  {
82  return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_core');
83  }
84 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:81
‪TYPO3\CMS\Core\Hooks\SiteDataHandlerCacheHook
Definition: SiteDataHandlerCacheHook.php:32
‪TYPO3\CMS\Core\Hooks\SiteDataHandlerCacheHook\getCache
‪FrontendInterface getCache()
Definition: SiteDataHandlerCacheHook.php:80
‪TYPO3\CMS\Core\Cache\CacheManager
Definition: CacheManager.php:34
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface
Definition: FrontendInterface.php:21
‪TYPO3\CMS\Core\Hooks\SiteDataHandlerCacheHook\processDatamap_afterDatabaseOperations
‪processDatamap_afterDatabaseOperations(string $status, string $table, $recordId, array $updatedFields, DataHandler $dataHandler)
Definition: SiteDataHandlerCacheHook.php:42
‪TYPO3\CMS\Core\Hooks\SiteDataHandlerCacheHook\processCmdmap_postProcess
‪processCmdmap_postProcess(string $command, string $table, $id, $value, DataHandler $dataHandler, $pasteUpdate, array $pasteDatamap)
Definition: SiteDataHandlerCacheHook.php:67
‪TYPO3\CMS\Core\Cache\Frontend\FrontendInterface\remove
‪bool remove($entryIdentifier)
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Routing\SiteMatcher
Definition: SiteMatcher.php:53
‪TYPO3\CMS\Core\Hooks
Definition: BackendUserGroupIntegrityCheck.php:2