44
44
use Symfony \Component \Debug \ErrorHandler ;
45
45
use Symfony \Component \Debug \Exception \FatalThrowableError ;
46
46
use Symfony \Component \EventDispatcher \EventDispatcherInterface ;
47
+ use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
47
48
48
49
/**
49
50
* An Application is the container for a collection of commands.
@@ -92,7 +93,7 @@ public function __construct(string $name = 'UNKNOWN', string $version = 'UNKNOWN
92
93
93
94
public function setDispatcher (EventDispatcherInterface $ dispatcher )
94
95
{
95
- $ this ->dispatcher = $ dispatcher ;
96
+ $ this ->dispatcher = LegacyEventDispatcherProxy:: decorate ( $ dispatcher) ;
96
97
}
97
98
98
99
public function setCommandLoader (CommandLoaderInterface $ commandLoader )
@@ -235,7 +236,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
235
236
if (!($ e instanceof CommandNotFoundException && !$ e instanceof NamespaceNotFoundException) || 1 !== \count ($ alternatives = $ e ->getAlternatives ()) || !$ input ->isInteractive ()) {
236
237
if (null !== $ this ->dispatcher ) {
237
238
$ event = new ConsoleErrorEvent ($ input , $ output , $ e );
238
- $ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
239
+ $ this ->dispatcher ->dispatch ($ event , ConsoleEvents::ERROR );
239
240
240
241
if (0 === $ event ->getExitCode ()) {
241
242
return 0 ;
@@ -254,7 +255,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
254
255
if (!$ style ->confirm (sprintf ('Do you want to run "%s" instead? ' , $ alternative ), false )) {
255
256
if (null !== $ this ->dispatcher ) {
256
257
$ event = new ConsoleErrorEvent ($ input , $ output , $ e );
257
- $ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
258
+ $ this ->dispatcher ->dispatch ($ event , ConsoleEvents::ERROR );
258
259
259
260
return $ event ->getExitCode ();
260
261
}
@@ -920,7 +921,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
920
921
$ e = null ;
921
922
922
923
try {
923
- $ this ->dispatcher ->dispatch (ConsoleEvents::COMMAND , $ event );
924
+ $ this ->dispatcher ->dispatch ($ event , ConsoleEvents::COMMAND );
924
925
925
926
if ($ event ->commandShouldRun ()) {
926
927
$ exitCode = $ command ->run ($ input , $ output );
@@ -929,7 +930,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
929
930
}
930
931
} catch (\Throwable $ e ) {
931
932
$ event = new ConsoleErrorEvent ($ input , $ output , $ e , $ command );
932
- $ this ->dispatcher ->dispatch (ConsoleEvents::ERROR , $ event );
933
+ $ this ->dispatcher ->dispatch ($ event , ConsoleEvents::ERROR );
933
934
$ e = $ event ->getError ();
934
935
935
936
if (0 === $ exitCode = $ event ->getExitCode ()) {
@@ -938,7 +939,7 @@ protected function doRunCommand(Command $command, InputInterface $input, OutputI
938
939
}
939
940
940
941
$ event = new ConsoleTerminateEvent ($ command , $ input , $ output , $ exitCode );
941
- $ this ->dispatcher ->dispatch (ConsoleEvents::TERMINATE , $ event );
942
+ $ this ->dispatcher ->dispatch ($ event , ConsoleEvents::TERMINATE );
942
943
943
944
if (null !== $ e ) {
944
945
throw $ e ;
0 commit comments