From 01b68b27f8a6f71cfb5dc2d4bec12bcfce7f0175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Ostroluck=C3=BD?= Date: Mon, 19 Aug 2024 21:00:02 +0200 Subject: [PATCH] Make symfony/console dependency truly optional Fixes #726 --- src/Resources/config/services.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php index 46c11e19..4e115327 100644 --- a/src/Resources/config/services.php +++ b/src/Resources/config/services.php @@ -8,6 +8,7 @@ use Snc\RedisBundle\Command\RedisQueryCommand; use Snc\RedisBundle\Factory\PhpredisClientFactory; use Snc\RedisBundle\Logger\RedisCallInterceptor; +use Symfony\Component\Console\Command\Command; use Symfony\Component\DependencyInjection\Definition; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\DependencyInjection\Loader\Configurator\InlineServiceConfigurator; @@ -26,13 +27,15 @@ ->tag('data_collector', ['id' => 'redis', 'template' => '@SncRedis/Collector/redis.html.twig']) ->args([new ReferenceConfigurator('snc_redis.logger')]); - $container->set(RedisQueryCommand::class) - ->tag('console.command', ['command' => RedisQueryCommand::COMMAND_NAME]) - ->args([ - tagged_locator('snc_redis.client', 'alias'), - (new ReferenceConfigurator('var_dumper.cli_dumper'))->nullOnInvalid(), - (new ReferenceConfigurator('var_dumper.cloner'))->nullOnInvalid(), - ]); + if (class_exists(Command::class)) { + $container->set(RedisQueryCommand::class) + ->tag('console.command', ['command' => RedisQueryCommand::COMMAND_NAME]) + ->args([ + tagged_locator('snc_redis.client', 'alias'), + (new ReferenceConfigurator('var_dumper.cli_dumper'))->nullOnInvalid(), + (new ReferenceConfigurator('var_dumper.cloner'))->nullOnInvalid(), + ]); + } $container->set(RedisCallInterceptor::class) ->class(RedisCallInterceptor::class)