Skip to content

Commit 6cf6f93

Browse files
committed
feat: spark config:check shows Config Caching state
1 parent ff7c020 commit 6cf6f93

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

system/Commands/Utilities/ConfigCheck.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313

1414
namespace CodeIgniter\Commands\Utilities;
1515

16+
use CodeIgniter\Cache\FactoriesCache;
1617
use CodeIgniter\CLI\BaseCommand;
1718
use CodeIgniter\CLI\CLI;
1819
use CodeIgniter\Config\BaseConfig;
20+
use Config\Optimize;
1921
use Kint\Kint;
2022

2123
/**
@@ -87,6 +89,14 @@ public function run(array $params)
8789
/** @var class-string<BaseConfig> $class */
8890
$class = $params[0];
8991

92+
// Load Config cache if it is enabled.
93+
$configCacheEnabled = class_exists(Optimize::class)
94+
&& (new Optimize())->configCacheEnabled;
95+
if ($configCacheEnabled) {
96+
$factoriesCache = new FactoriesCache();
97+
$factoriesCache->load('config');
98+
}
99+
90100
$config = config($class);
91101

92102
if ($config === null) {
@@ -103,6 +113,10 @@ public function run(array $params)
103113
);
104114
}
105115

116+
CLI::newLine();
117+
$state = CLI::color($configCacheEnabled ? 'Enabled' : 'Disabled', 'green');
118+
CLI::write('Config Caching: ' . $state);
119+
106120
return EXIT_SUCCESS;
107121
}
108122

0 commit comments

Comments
 (0)