28
28
use Symfony \Component \Console \Output \OutputInterface ;
29
29
use Symfony \Component \DependencyInjection \ContainerAwareInterface ;
30
30
use Symfony \Component \EventDispatcher \EventDispatcher ;
31
- use Symfony \Component \EventDispatcher \LegacyEventDispatcherProxy ;
32
31
33
32
/**
34
33
* Main application for PHPCRSH.
@@ -100,7 +99,7 @@ public function init()
100
99
$ this ->registerShellCommands ();
101
100
102
101
$ event = new ApplicationInitEvent ($ this );
103
- $ this ->dispatch (PhpcrShellEvents::APPLICATION_INIT , $ event );
102
+ $ this ->dispatcher -> dispatch ($ event , PhpcrShellEvents::APPLICATION_INIT );
104
103
$ this ->initialized = true ;
105
104
}
106
105
@@ -247,7 +246,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
247
246
$ name = $ this ->getCommandName ($ input );
248
247
249
248
$ event = new Event \CommandPreRunEvent ($ name , $ input );
250
- $ this ->dispatch (PhpcrShellEvents::COMMAND_PRE_RUN , $ event );
249
+ $ this ->dispatcher -> dispatch ($ event , PhpcrShellEvents::COMMAND_PRE_RUN );
251
250
$ input = $ event ->getInput ();
252
251
253
252
if (!$ name ) {
@@ -257,7 +256,7 @@ public function doRun(InputInterface $input, OutputInterface $output)
257
256
try {
258
257
$ exitCode = parent ::doRun ($ input , $ output );
259
258
} catch (\Exception $ e ) {
260
- $ this ->dispatch (PhpcrShellEvents:: COMMAND_EXCEPTION , new Event \CommandExceptionEvent ($ e , $ this , $ output ));
259
+ $ this ->dispatcher -> dispatch (new Event \CommandExceptionEvent ($ e , $ this , $ output ), PhpcrShellEvents:: COMMAND_EXCEPTION );
261
260
262
261
return 1 ;
263
262
}
@@ -297,7 +296,7 @@ public function add(Command $command)
297
296
public function dispatchProfileInitEvent (InputInterface $ sessionInput , OutputInterface $ output )
298
297
{
299
298
$ event = new Event \ProfileInitEvent ($ this ->container ->get ('config.profile ' ), $ sessionInput , $ output );
300
- $ this ->dispatch (PhpcrShellEvents::PROFILE_INIT , $ event );
299
+ $ this ->dispatch ($ event , PhpcrShellEvents::PROFILE_INIT );
301
300
}
302
301
303
302
/**
@@ -334,14 +333,4 @@ public function setDebug($debug)
334
333
{
335
334
$ this ->debug = $ debug ;
336
335
}
337
-
338
- private function dispatch (string $ eventName , $ event )
339
- {
340
- // LegacyEventDispatcherProxy exists in Symfony >= 4.3
341
- if (class_exists (LegacyEventDispatcherProxy::class)) {
342
- return $ this ->dispatcher ->dispatch ($ event , $ eventName );
343
- }
344
-
345
- return $ this ->dispatcher ->dispatch ($ eventName , $ event );
346
- }
347
336
}
0 commit comments