Skip to content

Commit 4c012b9

Browse files
committed
add clear cache for license check
1 parent 9f7cc17 commit 4c012b9

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/Commands/ClearCacheCommand.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace SolutionForest\InspireCms\Commands;
44

55
use Illuminate\Console\Command;
6+
use SolutionForest\InspireCms\Licensing\LicenseManager;
67
use Symfony\Component\Console\Attribute\AsCommand;
78
use Symfony\Component\Console\Input\InputOption;
89

@@ -13,6 +14,7 @@ class ClearCacheCommand extends Command
1314
'languages' => 'languages',
1415
'routes' => 'routes',
1516
'navigation' => 'navigation',
17+
'offline_licenses' => 'offline licenses',
1618
];
1719

1820
protected function configure()
@@ -63,22 +65,24 @@ protected function clearSelectedCaches(): void
6365

6466
protected function clearCache(string $type): void
6567
{
66-
if (in_array($type, ['languages', 'routes', 'navigation'])) {
68+
if (in_array($type, array_keys(static::CACHE_TYPES))) {
6769
$this->wrapClearCache($type, function ($type) {
6870

6971
switch ($type) {
7072
case 'languages':
7173
inspirecms()->forgetCachedLanguages();
72-
7374
break;
75+
7476
case 'routes':
7577
inspirecms()->forgetCachedContentRoutes();
76-
77-
// $this->callSilent('route:clear');
7878
break;
79+
7980
case 'navigation':
8081
inspirecms()->forgetCachedNavigation();
82+
break;
8183

84+
case 'offline_licenses':
85+
app(LicenseManager::class)->optimize();
8286
break;
8387
}
8488
});

src/Licensing/LicenseManager.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ public function getLicenseKey()
3131
return InspireCmsConfig::get('system.license.key');
3232
}
3333

34+
public function optimize()
35+
{
36+
// Clear the cache for license verification
37+
$this->cache()->forget($this->buildCacheKey());
38+
// Remove the license file if it exists
39+
if ($this->usingLicenseKeyFile()) {
40+
File::delete($this->licenseKeyPath());
41+
}
42+
}
43+
3444
/**
3545
* @return LicenseVerificationResult
3646
*/

0 commit comments

Comments
 (0)