diff --git a/src/Components/Health/HealthCollection.php b/src/Components/Health/HealthCollection.php index ca67e5cd..05c3393b 100644 --- a/src/Components/Health/HealthCollection.php +++ b/src/Components/Health/HealthCollection.php @@ -25,6 +25,16 @@ public function sortByState(): void }); } + /** + * @param array $ids + */ + public function removeByIds(array $ids): void + { + $this->elements = array_filter($this->elements, static function (SettingsResult $result) use ($ids) { + return !\in_array($result->id, $ids, true); + }); + } + protected function getExpectedClass(): ?string { return SettingsResult::class; diff --git a/src/Components/Health/SettingsResult.php b/src/Components/Health/SettingsResult.php index 057f32fa..e246e287 100644 --- a/src/Components/Health/SettingsResult.php +++ b/src/Components/Health/SettingsResult.php @@ -21,7 +21,7 @@ class SettingsResult extends Struct public ?string $url = null; - protected string $id; + public string $id; protected string $snippet; diff --git a/src/Controller/HealthController.php b/src/Controller/HealthController.php index 0c0544d5..589e56be 100644 --- a/src/Controller/HealthController.php +++ b/src/Controller/HealthController.php @@ -8,6 +8,7 @@ use Frosh\Tools\Components\Health\HealthCollection; use Frosh\Tools\Components\Health\PerformanceCollection; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\AutowireIterator; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\Routing\Attribute\Route; @@ -27,6 +28,8 @@ public function __construct( #[AutowireIterator('frosh_tools.performance_checker')] private readonly iterable $performanceCheckers, private readonly CacheInterface $cacheObject, + #[Autowire(param: 'frosh_tools.checker.disabled_checks')] + private readonly array $ignoredChecks ) { } @@ -39,6 +42,7 @@ public function status(): JsonResponse } $collection->sortByState(); + $collection->removeByIds($this->ignoredChecks); return new JsonResponse($collection); } @@ -52,6 +56,7 @@ public function performanceStatus(): JsonResponse } $collection->sortByState(); + $collection->removeByIds($this->ignoredChecks); return new JsonResponse($collection); } diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index f27301c2..7db15cfa 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -16,6 +16,14 @@ public function getConfigTreeBuilder(): TreeBuilder $rootNode = $treeBuilder->getRootNode(); $rootNode ->children() + ->arrayNode('checker') + ->children() + ->arrayNode('disabled_checks') + ->scalarPrototype() + ->end() + ->end() + ->end() + ->end() ->arrayNode('file_checker') ->children() ->arrayNode('exclude_files') diff --git a/src/DependencyInjection/FroshToolsExtension.php b/src/DependencyInjection/FroshToolsExtension.php index b53204a9..dc641f27 100644 --- a/src/DependencyInjection/FroshToolsExtension.php +++ b/src/DependencyInjection/FroshToolsExtension.php @@ -44,8 +44,8 @@ private function addConfig(ContainerBuilder $container, string $alias, array $op $container->setParameter('frosh_tools.file_checker.exclude_files', []); } - if (!$container->hasParameter('frosh_tools.system_config')) { - $container->setParameter('frosh_tools.system_config', []); + if (!$container->hasParameter('frosh_tools.checker.disabled_checks')) { + $container->setParameter('frosh_tools.checker.disabled_checks', []); } } }