@@ -27,12 +27,12 @@ The most common way to listen to an event is to register an **event listener**::
2727 namespace App\EventListener;
2828
2929 use Symfony\Component\HttpFoundation\Response;
30- use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent ;
30+ use Symfony\Component\HttpKernel\Event\ExceptionEvent ;
3131 use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
3232
3333 class ExceptionListener
3434 {
35- public function onKernelException(GetResponseForExceptionEvent $event)
35+ public function onKernelException(ExceptionEvent $event)
3636 {
3737 // You get the exception object from the received event
3838 $exception = $event->getException();
@@ -63,10 +63,16 @@ The most common way to listen to an event is to register an **event listener**::
6363.. tip ::
6464
6565 Each event receives a slightly different type of ``$event `` object. For
66- the ``kernel.exception `` event, it is :class: `Symfony\\ Component\\ HttpKernel\\ Event\\ GetResponseForExceptionEvent `.
66+ the ``kernel.exception `` event, it is :class: `Symfony\\ Component\\ HttpKernel\\ Event\\ ExceptionEvent `.
6767 Check out the :doc: `Symfony events reference </reference/events >` to see
6868 what type of object each event provides.
6969
70+ .. versionadded ::
71+
72+ The :class: `Symfony\\ Component\\ HttpKernel\\ Event\\ ExceptionEvent ` class was
73+ introduced in Symfony 4.3. In previous versions it was called
74+ ``Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent ``.
75+
7076Now that the class is created, you need to register it as a service and
7177notify Symfony that it is a "listener" on the ``kernel.exception `` event by
7278using a special "tag":
@@ -151,7 +157,7 @@ listen to the same ``kernel.exception`` event::
151157 namespace App\EventSubscriber;
152158
153159 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
154- use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent ;
160+ use Symfony\Component\HttpKernel\Event\ExceptionEvent ;
155161 use Symfony\Component\HttpKernel\KernelEvents;
156162
157163 class ExceptionSubscriber implements EventSubscriberInterface
@@ -168,17 +174,17 @@ listen to the same ``kernel.exception`` event::
168174 ];
169175 }
170176
171- public function processException(GetResponseForExceptionEvent $event)
177+ public function processException(ExceptionEvent $event)
172178 {
173179 // ...
174180 }
175181
176- public function logException(GetResponseForExceptionEvent $event)
182+ public function logException(ExceptionEvent $event)
177183 {
178184 // ...
179185 }
180186
181- public function notifyException(GetResponseForExceptionEvent $event)
187+ public function notifyException(ExceptionEvent $event)
182188 {
183189 // ...
184190 }
@@ -207,11 +213,11 @@ or a "sub request"::
207213 // src/EventListener/RequestListener.php
208214 namespace App\EventListener;
209215
210- use Symfony\Component\HttpKernel\Event\GetResponseEvent ;
216+ use Symfony\Component\HttpKernel\Event\RequestEvent ;
211217
212218 class RequestListener
213219 {
214- public function onKernelRequest(GetResponseEvent $event)
220+ public function onKernelRequest(RequestEvent $event)
215221 {
216222 if (!$event->isMasterRequest()) {
217223 // don't do anything if it's not the master request
0 commit comments