Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 430de15

Browse filesBrowse files
committed
don't explain deprecated getName() method
1 parent 1f343b1 commit 430de15
Copy full SHA for 430de15

File tree

Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-9
lines changed

‎components/event_dispatcher/introduction.rst

Copy file name to clipboardExpand all lines: components/event_dispatcher/introduction.rst
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -626,22 +626,21 @@ 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.
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

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.