File tree Expand file tree Collapse file tree 1 file changed +5
-10
lines changed
components/event_dispatcher Expand file tree Collapse file tree 1 file changed +5
-10
lines changed Original file line number Diff line number Diff line change @@ -626,22 +626,17 @@ 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.
634
-
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::
629
+ The `EventDispatcher ` instance as well as the name of the dispatched event
630
+ itself, are passed as arguments to the listener::
637
631
638
632
use Symfony\Component\EventDispatcher\Event;
633
+ use Symfony\Component\EventDispatcher\EventDispatcher;
639
634
640
635
class Foo
641
636
{
642
- public function myEventListener(Event $event)
637
+ public function myEventListener(Event $event, $eventName, EventDispatcher $dispatcher )
643
638
{
644
- echo $event->getName() ;
639
+ echo $eventName ;
645
640
}
646
641
}
647
642
You can’t perform that action at this time.
0 commit comments