|
14 | 14 | use Symfony\Component\Console\Event\ConsoleCommandEvent; |
15 | 15 | use Symfony\Component\Console\Event\ConsoleErrorEvent; |
16 | 16 | use Symfony\Component\Console\Event\ConsoleTerminateEvent; |
| 17 | +use Symfony\Component\EventDispatcher\Event as LegacyEvent; |
17 | 18 | use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
| 19 | +use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent; |
| 20 | +use Symfony\Component\HttpKernel\Event\ControllerEvent; |
| 21 | +use Symfony\Component\HttpKernel\Event\ExceptionEvent; |
18 | 22 | use Symfony\Component\HttpKernel\Event\FilterControllerArgumentsEvent; |
19 | 23 | use Symfony\Component\HttpKernel\Event\FilterControllerEvent; |
20 | 24 | use Symfony\Component\HttpKernel\Event\FilterResponseEvent; |
|
23 | 27 | use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent; |
24 | 28 | use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; |
25 | 29 | use Symfony\Component\HttpKernel\Event\PostResponseEvent; |
26 | | -use Symfony\Component\HttpKernel\Event\ControllerArgumentsEvent; |
27 | | -use Symfony\Component\HttpKernel\Event\ControllerEvent; |
28 | | -use Symfony\Component\HttpKernel\Event\ResponseEvent; |
29 | 30 | use Symfony\Component\HttpKernel\Event\RequestEvent; |
30 | | -use Symfony\Component\HttpKernel\Event\ViewEvent; |
31 | | -use Symfony\Component\HttpKernel\Event\ExceptionEvent; |
| 31 | +use Symfony\Component\HttpKernel\Event\ResponseEvent; |
32 | 32 | use Symfony\Component\HttpKernel\Event\TerminateEvent; |
| 33 | +use Symfony\Component\HttpKernel\Event\ViewEvent; |
33 | 34 | use Symfony\Component\Security\Core\Event\AuthenticationEvent; |
34 | 35 | use Symfony\Component\Security\Core\Event\AuthenticationFailureEvent; |
35 | 36 | use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; |
36 | 37 | use Symfony\Component\Security\Http\Event\SwitchUserEvent; |
| 38 | +use Symfony\Contracts\EventDispatcher\Event; |
37 | 39 |
|
38 | 40 | /** |
39 | 41 | * @internal |
@@ -76,10 +78,10 @@ public function __construct(EventDispatcherInterface $eventDispatcher) |
76 | 78 | $this->eventDispatcher = $eventDispatcher; |
77 | 79 |
|
78 | 80 | // Loop through the new event classes |
79 | | - foreach (self::$newEventsMap as $oldEventName => $newEventClass) { |
| 81 | + foreach (self::$newEventsMap as $eventName => $newEventClass) { |
80 | 82 | //Check if the new event classes exist, if so replace the old one with the new. |
81 | | - if (isset(self::$eventsMap[$oldEventName]) && class_exists($newEventClass)) { |
82 | | - unset(self::$eventsMap[$oldEventName]); |
| 83 | + if (isset(self::$eventsMap[$eventName]) && class_exists($newEventClass)) { |
| 84 | + unset(self::$eventsMap[$eventName]); |
83 | 85 | self::$eventsMap[$newEventClass] = $newEventClass; |
84 | 86 | } |
85 | 87 | } |
@@ -141,7 +143,13 @@ public function getEventClassName(string $event) |
141 | 143 | } |
142 | 144 |
|
143 | 145 | if (null !== $type = $args[0]->getType()) { |
144 | | - return (string) $type; |
| 146 | + $type = $type instanceof \ReflectionNamedType ? $type->getName() : $type->__toString(); |
| 147 | + |
| 148 | + if (LegacyEvent::class === $type && class_exists(Event::class)) { |
| 149 | + return Event::class; |
| 150 | + } |
| 151 | + |
| 152 | + return $type; |
145 | 153 | } |
146 | 154 | } |
147 | 155 |
|
|
0 commit comments