Skip to content

Commit 05df80f

Browse files
kbondfabpot
authored andcommitted
[Console][Messenger] add RunCommandMessage and RunCommandMessageHandler
1 parent afefa62 commit 05df80f

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
use Symfony\Component\Config\ResourceCheckerInterface;
5454
use Symfony\Component\Console\Application;
5555
use Symfony\Component\Console\Command\Command;
56+
use Symfony\Component\Console\Messenger\RunCommandMessageHandler;
5657
use Symfony\Component\DependencyInjection\Alias;
5758
use Symfony\Component\DependencyInjection\Argument\ServiceClosureArgument;
5859
use Symfony\Component\DependencyInjection\ChildDefinition;
@@ -253,6 +254,11 @@ public function load(array $configs, ContainerBuilder $container)
253254
if (!class_exists(DebugCommand::class)) {
254255
$container->removeDefinition('console.command.dotenv_debug');
255256
}
257+
258+
if (!class_exists(RunCommandMessageHandler::class)) {
259+
$container->removeDefinition('console.messenger.application');
260+
$container->removeDefinition('console.messenger.execute_command_handler');
261+
}
256262
}
257263

258264
// Load Cache configuration first as it is used by other components

Resources/config/console.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
3939
use Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand;
4040
use Symfony\Bundle\FrameworkBundle\Command\YamlLintCommand;
41+
use Symfony\Bundle\FrameworkBundle\Console\Application;
4142
use Symfony\Bundle\FrameworkBundle\EventListener\SuggestMissingPackageSubscriber;
4243
use Symfony\Component\Console\EventListener\ErrorListener;
44+
use Symfony\Component\Console\Messenger\RunCommandMessageHandler;
4345
use Symfony\Component\Dotenv\Command\DebugCommand as DotenvDebugCommand;
4446
use Symfony\Component\Messenger\Command\ConsumeMessagesCommand;
4547
use Symfony\Component\Messenger\Command\DebugCommand as MessengerDebugCommand;
@@ -364,5 +366,18 @@
364366
service('secrets.local_vault')->ignoreOnInvalid(),
365367
])
366368
->tag('console.command')
369+
370+
->set('console.messenger.application', Application::class)
371+
->share(false)
372+
->call('setAutoExit', [false])
373+
->args([
374+
service('kernel'),
375+
])
376+
377+
->set('console.messenger.execute_command_handler', RunCommandMessageHandler::class)
378+
->args([
379+
service('console.messenger.application'),
380+
])
381+
->tag('messenger.message_handler')
367382
;
368383
};

0 commit comments

Comments
 (0)