Skip to content

Commit afbffc0

Browse files
committed
don't explain deprecated getName() method
1 parent 1f343b1 commit afbffc0

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

components/event_dispatcher/introduction.rst

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -626,22 +626,17 @@ and so on...
626626
Event 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.
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::
637631

638632
use Symfony\Component\EventDispatcher\Event;
633+
use Symfony\Component\EventDispatcher\EventDispatcher;
639634

640635
class Foo
641636
{
642-
public function myEventListener(Event $event)
637+
public function myEventListener(Event $event, $eventName, EventDispatcher $dispatcher)
643638
{
644-
echo $event->getName();
639+
echo $eventName;
645640
}
646641
}
647642

0 commit comments

Comments
 (0)