Skip to content
This repository was archived by the owner on Aug 15, 2023. It is now read-only.

Commit c3ca8c1

Browse files
author
Stefano Kowalke
committed
[FEATURE] Adding option to clear all caches hard like in install tool
Resolves: #91
1 parent b4ce845 commit c3ca8c1

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

Classes/Command/CacheApiCommandController.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,16 @@ public function injectCacheApiService(\Etobi\CoreAPI\Service\CacheApiService $ca
7676

7777
/**
7878
* Clear all caches.
79+
* If hard, cache will be cleared in a more straightforward approach and the according backend hooks are not executed.
7980
*
81+
* @param boolean $hard
8082
* @return void
8183
*/
82-
public function clearAllCachesCommand() {
83-
$this->cacheApiService->clearAllCaches();
84-
$message = 'All caches have been cleared.';
84+
public function clearAllCachesCommand($hard = false) {
85+
$this->cacheApiService->clearAllCaches($hard);
86+
$message = 'All caches have been cleared%s.';
8587
$this->logger->info($message);
86-
$this->outputLine($message);
88+
$this->outputLine($message, $hard ? array(' hard') : array(''));
8789
}
8890

8991
/**

Classes/Service/CacheApiService.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ class CacheApiService {
4747
*/
4848
protected $objectManager;
4949

50+
/**
51+
* @var \TYPO3\CMS\Install\Service\ClearCacheService
52+
*/
53+
protected $installToolClearCacheService;
54+
5055
/**
5156
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $dataHandler
5257
*
@@ -65,6 +70,15 @@ public function injectObjectManager(\TYPO3\CMS\Extbase\Object\ObjectManager $obj
6570
$this->objectManager = $objectManager;
6671
}
6772

73+
/**
74+
* @param \TYPO3\CMS\Install\Service\ClearCacheService $installToolClearCacheService
75+
*
76+
* @return void
77+
*/
78+
public function injectInstallToolClearCacheService(\TYPO3\CMS\Install\Service\ClearCacheService $installToolClearCacheService) {
79+
$this->installToolClearCacheService = $installToolClearCacheService;
80+
}
81+
6882
/**
6983
* Initialize the object.
7084
*
@@ -84,10 +98,11 @@ public function initializeObject() {
8498
/**
8599
* Clear all caches.
86100
*
101+
* @param bool $hard
87102
* @return void
88103
*/
89-
public function clearAllCaches() {
90-
$this->dataHandler->clear_cacheCmd('all');
104+
public function clearAllCaches($hard = FALSE) {
105+
!$hard ? $this->dataHandler->clear_cacheCmd('all') : $this->installToolClearCacheService->clearAll();
91106
}
92107

93108
/**

0 commit comments

Comments
 (0)