File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed
components/event_dispatcher Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -626,22 +626,21 @@ and so on...
626626Event Name Introspection
627627~~~~~~~~~~~~~~~~~~~~~~~~
628628
629- Since the ``EventDispatcher `` already knows the name of the event when dispatching
630- it, the event name is also injected into the
631- :class: `Symfony\\ Component\\ EventDispatcher\\ Event ` objects, making it available
632- to event listeners via the :method: `Symfony\\ Component\\ EventDispatcher\\ Event::getName `
633- method.
629+ .. versionadded :: 2.4
630+ Before Symfony 2.4, the event name and the event dispatcher had to be
631+ requested from the ``Event `` instance. These methods are now deprecated.
634632
635- The event name, ( as with any other data in a custom event object) can be used as
636- part of the listener's processing logic ::
633+ The `` EventDispatcher `` instance, as well as the name of the event that is
634+ dispatched, are passed as arguments to the listener ::
637635
638636 use Symfony\Component\EventDispatcher\Event;
637+ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
639638
640639 class Foo
641640 {
642- public function myEventListener(Event $event)
641+ public function myEventListener(Event $event, $eventName, EventDispatcherInterface $dispatcher )
643642 {
644- echo $event->getName() ;
643+ echo $eventName ;
645644 }
646645 }
647646
You can’t perform that action at this time.
0 commit comments