-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCacheCommandController.php
More file actions
59 lines (52 loc) · 1.73 KB
/
CacheCommandController.php
File metadata and controls
59 lines (52 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
namespace Networkteam\Util\Command;
/***************************************************************
* (c) 2017 networkteam GmbH - all rights reserved
***************************************************************/
use Neos\Flow\Annotations as Flow;
use Neos\Cache\Backend\SimpleFileBackend;
use Neos\Cache\Backend\TransientMemoryBackend;
use Neos\Cache\Backend\NullBackend;
class CacheCommandController extends \Neos\Flow\Cli\CommandController
{
/**
* @var \Neos\Flow\Cache\CacheManager
* @Flow\Inject
*/
protected $cacheManager;
/**
* @var \Neos\Flow\Configuration\ConfigurationManager
* @Flow\Inject
*/
protected $configurationManager;
/**
* Clears all non file caches
*/
public function clearNonFileCachesCommand(): void
{
$caches = $this->cacheManager->getCacheConfigurations();
foreach ($caches as $name => $configuration) {
$cache = $this->cacheManager->getCache($name);
$backend = $cache->getBackend();
if (!$backend instanceof SimpleFileBackend &&
!$backend instanceof NullBackend &&
!$backend instanceof TransientMemoryBackend
) {
$cache->flush();
$this->outputLine(sprintf('Flushed cache %s', $name));
}
}
}
/**
* Refresh configuration cache (flush and load again)
*/
public function refreshConfigCommand(): void
{
try {
$this->configurationManager->refreshConfiguration();
$this->outputLine('Configuration has been flushed and loaded again.');
} catch (\Exception $e) {
$this->outputLine(sprintf('Failed: %s', $e->getMessage()));
}
}
}