1
|
|
|
<?php |
2
|
|
|
declare(strict_types=1); |
3
|
|
|
|
4
|
|
|
namespace Filoucrackeur\StorageFrameworkManager\Service; |
5
|
|
|
|
6
|
|
|
use Filoucrackeur\StorageFrameworkManager\Domain\Model\Dto\CacheBackend; |
7
|
|
|
use Filoucrackeur\StorageFrameworkManager\Domain\Model\Dto\SessionBackend; |
8
|
|
|
use TYPO3\CMS\Core\SingletonInterface; |
9
|
|
|
|
10
|
|
|
class CacheManagerService implements SingletonInterface |
11
|
|
|
{ |
12
|
|
|
|
13
|
|
|
private const TYPO3_CORE_CACHE_IDENTIFIERS = [ |
14
|
|
|
'cache_core', |
15
|
|
|
'cache_hash', |
16
|
|
|
'cache_pages', |
17
|
|
|
'cache_pagesection', |
18
|
|
|
'cache_runtime', |
19
|
|
|
'cache_rootline', |
20
|
|
|
'cache_imagesizes', |
21
|
|
|
'assets', |
22
|
|
|
'l10n', |
23
|
|
|
'fluid_template', |
24
|
|
|
'extbase_reflection', |
25
|
|
|
'extbase_datamapfactory_datamap', |
26
|
|
|
'adminpanel_requestcache', |
27
|
|
|
]; |
28
|
|
|
|
29
|
|
|
private const TYPO3_SESSION_IDENTIFIERS = [ |
30
|
|
|
'BE', |
31
|
|
|
'FE', |
32
|
|
|
]; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var array |
36
|
|
|
*/ |
37
|
|
|
private $cacheExtensionsBackends = []; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return array |
41
|
|
|
*/ |
42
|
|
|
public function getSessionBackends(): array |
43
|
|
|
{ |
44
|
|
|
return self::TYPO3_SESSION_IDENTIFIERS; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @return array |
49
|
|
|
*/ |
50
|
|
|
public function getCacheCoreBackends(): array |
51
|
|
|
{ |
52
|
|
|
return self::TYPO3_CORE_CACHE_IDENTIFIERS; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return array |
57
|
|
|
*/ |
58
|
|
|
public function getCacheExtensionsBackends(): array |
59
|
|
|
{ |
60
|
|
|
$cacheConfigurations = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']; |
61
|
|
|
|
62
|
|
|
foreach ($cacheConfigurations as $identifier => $configuration) { |
63
|
|
|
if (!in_array($identifier, self::TYPO3_CORE_CACHE_IDENTIFIERS, true)) { |
64
|
|
|
$this->cacheExtensionsBackends[] = $identifier; |
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
return $this->cacheExtensionsBackends; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* @param string $identifier |
73
|
|
|
* @return CacheBackend |
74
|
|
|
*/ |
75
|
|
|
public function getCacheBackendByIdentifier(string $identifier): CacheBackend |
76
|
|
|
{ |
77
|
|
|
return new CacheBackend( |
78
|
|
|
$identifier, |
79
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$identifier]['backend'], |
80
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$identifier] |
81
|
|
|
); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $identifier |
86
|
|
|
* @return SessionBackend |
87
|
|
|
*/ |
88
|
|
|
public function getSessionBackendByIdentifier(string $identifier): SessionBackend |
89
|
|
|
{ |
90
|
|
|
return new SessionBackend( |
91
|
|
|
$identifier, |
92
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['session'][$identifier]['backend'], |
93
|
|
|
$GLOBALS['TYPO3_CONF_VARS']['SYS']['session'][$identifier] |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
} |