Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace Frosh\Tools\Components\Health\Checker\PerformanceChecker;

use Frosh\Tools\Components\Health\Checker\CheckerInterface;
use Frosh\Tools\Components\Health\HealthCollection;
use Frosh\Tools\Components\Health\SettingsResult;
use Symfony\Bundle\FrameworkBundle\Secrets\AbstractVault;
use Symfony\Component\DependencyInjection\Attribute\Autowire;

class DisableSymfonySecretsChecker implements PerformanceCheckerInterface, CheckerInterface
{
public function __construct(
#[Autowire(param: 'framework.secrets.enabled')]
private readonly bool $secretsEnabled,
#[Autowire(service: 'secrets.vault')]
private readonly AbstractVault $vault,
#[Autowire(service: 'secrets.local_vault')]
private readonly ?AbstractVault $localVault = null,
) {}

public function collect(HealthCollection $collection): void
{
if ($this->secretsEnabled && !$this->areSecretsInUse()) {
$collection->add(
SettingsResult::info(
'symfony-secrets',
'Disable Symfony Secrets',
'enabled',
'disabled',
'https://developer.shopware.com/docs/guides/hosting/performance/performance-tweaks.html#disable-symfony-secrets',
),
);
}
}

private function areSecretsInUse(): bool
{
return count($this->vault->list()) > 0 || ($this->localVault instanceof AbstractVault && count($this->localVault->list()) > 0);
}
}
4 changes: 4 additions & 0 deletions src/DependencyInjection/SymfonyConfigCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,9 @@ public function process(ContainerBuilder $container): void
if (!$container->hasParameter('shopware.cache.tagging.each_theme_config')) {
$container->setParameter('shopware.cache.tagging.each_theme_config', true);
}

if (!$container->hasParameter('framework.secrets.enabled')) {
$container->setParameter('framework.secrets.enabled', true);
}
}
}
Loading