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...
626
626
Event Name Introspection
627
627
~~~~~~~~~~~~~~~~~~~~~~~~
628
628
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.
634
632
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 ::
637
635
638
636
use Symfony\Component\EventDispatcher\Event;
637
+ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
639
638
640
639
class Foo
641
640
{
642
- public function myEventListener(Event $event)
641
+ public function myEventListener(Event $event, $eventName, EventDispatcherInterface $dispatcher )
643
642
{
644
- echo $event->getName() ;
643
+ echo $eventName ;
645
644
}
646
645
}
647
646
You can’t perform that action at this time.
0 commit comments