File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed
Components/Health/Checker/PerformanceChecker Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Frosh \Tools \Components \Health \Checker \PerformanceChecker ;
6+
7+ use Frosh \Tools \Components \Health \Checker \CheckerInterface ;
8+ use Frosh \Tools \Components \Health \HealthCollection ;
9+ use Frosh \Tools \Components \Health \SettingsResult ;
10+ use Symfony \Bundle \FrameworkBundle \Secrets \AbstractVault ;
11+ use Symfony \Component \DependencyInjection \Attribute \Autowire ;
12+
13+ class DisableSymfonySecretsChecker implements PerformanceCheckerInterface, CheckerInterface
14+ {
15+ public function __construct (
16+ #[Autowire(param: 'framework.secrets.enabled ' )]
17+ private readonly bool $ secretsEnabled ,
18+ #[Autowire(service: 'secrets.vault ' )]
19+ private readonly AbstractVault $ vault ,
20+ #[Autowire(service: 'secrets.local_vault ' )]
21+ private readonly ?AbstractVault $ localVault = null ,
22+ ) {}
23+
24+ public function collect (HealthCollection $ collection ): void
25+ {
26+ if ($ this ->secretsEnabled && !$ this ->areSecretsInUse ()) {
27+ $ collection ->add (
28+ SettingsResult::info (
29+ 'symfony-secrets ' ,
30+ 'Disable Symfony Secrets ' ,
31+ 'enabled ' ,
32+ 'disabled ' ,
33+ 'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-symfony-secrets ' ,
34+ ),
35+ );
36+ }
37+ }
38+
39+ private function areSecretsInUse (): bool
40+ {
41+ return count ($ this ->vault ->list ()) > 0 || ($ this ->localVault instanceof AbstractVault && count ($ this ->localVault ->list ()) > 0 );
42+ }
43+ }
Original file line number Diff line number Diff line change @@ -43,5 +43,9 @@ public function process(ContainerBuilder $container): void
4343 if (!$ container ->hasParameter ('shopware.cache.tagging.each_theme_config ' )) {
4444 $ container ->setParameter ('shopware.cache.tagging.each_theme_config ' , true );
4545 }
46+
47+ if (!$ container ->hasParameter ('framework.secrets.enabled ' )) {
48+ $ container ->setParameter ('framework.secrets.enabled ' , true );
49+ }
4650 }
4751}
You can’t perform that action at this time.
0 commit comments