Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions event_dispatcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,30 @@ listener class:
internal Symfony listeners usually range from ``-255`` to ``255`` but your
own listeners can use any positive or negative integer.


.. tip::

When implementing both the :class:`Symfony\\Component\\EventDispatcher\\EventListenerInterface`
interface, and the ``__invoke`` method with a type-hinted argument, Symfony
uses that type-hint to define the event name.
If :ref:`autoconfigure <services-autoconfigure>` is enabled, you neither
don't have to manually define the ``kernel.event_listner`` tag.
Registering the previous listener could be simplified to::

// src/EventListener/ExceptionListener.php
namespace App\EventListener;

use Symfony\Component\EventDispatcher\EventListenerInterface;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;

class ExceptionListener implements EventListenerInterface
{
public function __invoke(ExceptionEvent $event)
{
// ...
}
}

.. _events-subscriber:

Creating an Event Subscriber
Expand Down