Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8e80991

Browse files
committed
minor #12007 Use new Event names (OskarStark)
This PR was squashed before being merged into the 4.3 branch (closes #12007). Discussion ---------- Use new Event names Based on symfony/symfony#28920 @symfony/team-symfony-docs shall we add `versionadded` directives? Commits ------- 00f3807 Use new Event names
2 parents 08f9c24 + 00f3807 commit 8e80991

File tree

11 files changed

+66
-53
lines changed

11 files changed

+66
-53
lines changed

components/event_dispatcher.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Often times, data about a specific event needs to be passed along with the
111111
case, a special subclass that has additional methods for retrieving and
112112
overriding information can be passed when dispatching an event. For example,
113113
the ``kernel.response`` event uses a
114-
:class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent`, which
114+
:class:`Symfony\\Component\\HttpKernel\\Event\\ResponseEvent`, which
115115
contains methods to get and even replace the ``Response`` object.
116116

117117
The Dispatcher
@@ -334,7 +334,7 @@ Take the following example of a subscriber that subscribes to the
334334

335335
use Acme\Store\Event\OrderPlacedEvent;
336336
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
337-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
337+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
338338
use Symfony\Component\HttpKernel\KernelEvents;
339339

340340
class StoreSubscriber implements EventSubscriberInterface
@@ -350,12 +350,12 @@ Take the following example of a subscriber that subscribes to the
350350
];
351351
}
352352

353-
public function onKernelResponsePre(FilterResponseEvent $event)
353+
public function onKernelResponsePre(ResponseEvent $event)
354354
{
355355
// ...
356356
}
357357

358-
public function onKernelResponsePost(FilterResponseEvent $event)
358+
public function onKernelResponsePost(ResponseEvent $event)
359359
{
360360
// ...
361361
}

components/http_kernel.rst

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ have been determined (e.g. the controller, routing information) but before
292292
the controller is executed. For some examples, see the Symfony section below.
293293

294294
Listeners to this event can also change the controller callable completely
295-
by calling :method:`FilterControllerEvent::setController <Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent::setController>`
295+
by calling :method:`ControllerEvent::setController <Symfony\\Component\\HttpKernel\\Event\\ControllerEvent::setController>`
296296
on the event object that's passed to listeners on this event.
297297

298298
.. sidebar:: ``kernel.controller`` in the Symfony Framework
@@ -524,9 +524,9 @@ to the exception.
524524

525525
<object data="../_images/components/http_kernel/http-workflow-exception.svg" type="image/svg+xml"></object>
526526

527-
Each listener to this event is passed a :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`
527+
Each listener to this event is passed a :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent`
528528
object, which you can use to access the original exception via the
529-
:method:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent::getException`
529+
:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException`
530530
method. A typical listener on this event will check for a certain type of
531531
exception and create an appropriate error ``Response``.
532532

@@ -602,18 +602,31 @@ each event has their own event object:
602602

603603
.. _component-http-kernel-event-table:
604604

605-
=========================== ====================================== ===================================================================================
605+
=========================== ====================================== ========================================================================
606606
Name ``KernelEvents`` Constant Argument passed to the listener
607-
=========================== ====================================== ===================================================================================
608-
kernel.request ``KernelEvents::REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent`
609-
kernel.controller ``KernelEvents::CONTROLLER`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent`
610-
kernel.controller_arguments ``KernelEvents::CONTROLLER_ARGUMENTS`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerArgumentsEvent`
611-
kernel.view ``KernelEvents::VIEW`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent`
612-
kernel.response ``KernelEvents::RESPONSE`` :class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent`
607+
=========================== ====================================== ========================================================================
608+
kernel.request ``KernelEvents::REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent`
609+
kernel.controller ``KernelEvents::CONTROLLER`` :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerEvent`
610+
kernel.controller_arguments ``KernelEvents::CONTROLLER_ARGUMENTS`` :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerArgumentsEvent`
611+
kernel.view ``KernelEvents::VIEW`` :class:`Symfony\\Component\\HttpKernel\\Event\\ViewEvent`
612+
kernel.response ``KernelEvents::RESPONSE`` :class:`Symfony\\Component\\HttpKernel\\Event\\ResponseEvent`
613613
kernel.finish_request ``KernelEvents::FINISH_REQUEST`` :class:`Symfony\\Component\\HttpKernel\\Event\\FinishRequestEvent`
614-
kernel.terminate ``KernelEvents::TERMINATE`` :class:`Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent`
615-
kernel.exception ``KernelEvents::EXCEPTION`` :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`
616-
=========================== ====================================== ===================================================================================
614+
kernel.terminate ``KernelEvents::TERMINATE`` :class:`Symfony\\Component\\HttpKernel\\Event\\TerminateEvent`
615+
kernel.exception ``KernelEvents::EXCEPTION`` :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent`
616+
=========================== ====================================== ========================================================================
617+
618+
.. deprecated:: 4.3
619+
620+
Since Symfony 4.3, most of the event classes were renamed.
621+
The following old classes were deprecated:
622+
623+
* `GetResponseEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent`
624+
* `FilterControllerEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerEvent`
625+
* `FilterControllerArgumentsEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerArgumentsEvent`
626+
* `GetResponseForControllerResultEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ViewEvent`
627+
* `FilterResponseEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ResponseEvent`
628+
* `PostResponseEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\TerminateEvent`
629+
* `GetResponseForExceptionEvent` renamed to :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent`
617630

618631
.. _http-kernel-working-example:
619632

@@ -709,10 +722,10 @@ can be used to check if the current request is a "master" or "sub" request.
709722
For example, a listener that only needs to act on the master request may
710723
look like this::
711724

712-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
725+
use Symfony\Component\HttpKernel\Event\RequestEvent;
713726
// ...
714727

715-
public function onKernelRequest(GetResponseEvent $event)
728+
public function onKernelRequest(RequestEvent $event)
716729
{
717730
if (!$event->isMasterRequest()) {
718731
return;

components/security/authentication.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ an *authenticated* token if the supplied credentials were found to be valid.
1313
The listener should then store the authenticated token using
1414
:class:`the token storage <Symfony\\Component\\Security\\Core\\Authentication\\Token\\Storage\\TokenStorageInterface>`::
1515

16-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
16+
use Symfony\Component\HttpKernel\Event\RequestEvent;
1717
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
1818
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
1919
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
@@ -38,7 +38,7 @@ The listener should then store the authenticated token using
3838

3939
// ...
4040

41-
public function handle(GetResponseEvent $event)
41+
public function handle(RequestEvent $event)
4242
{
4343
$request = $event->getRequest();
4444

controller/error_pages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ error pages.
339339
.. note::
340340

341341
If your listener calls ``setResponse()`` on the
342-
:class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`,
342+
:class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent`,
343343
event, propagation will be stopped and the response will be sent to
344344
the client.
345345

create_framework/http_kernel_httpkernel_class.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,11 @@ only if needed::
154154

155155
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
156156
use Symfony\Component\HttpFoundation\Response;
157-
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
157+
use Symfony\Component\HttpKernel\Event\ViewEvent;
158158

159159
class StringResponseListener implements EventSubscriberInterface
160160
{
161-
public function onView(GetResponseForControllerResultEvent $event)
161+
public function onView(ViewEvent $event)
162162
{
163163
$response = $event->getControllerResult();
164164

event_dispatcher/before_after_filters.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ event subscribers, you can learn more about them at :doc:`/event_dispatcher`::
115115

116116
use App\Controller\TokenAuthenticatedController;
117117
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
118-
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
118+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
119119
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
120120
use Symfony\Component\HttpKernel\KernelEvents;
121121

@@ -128,7 +128,7 @@ event subscribers, you can learn more about them at :doc:`/event_dispatcher`::
128128
$this->tokens = $tokens;
129129
}
130130

131-
public function onKernelController(FilterControllerEvent $event)
131+
public function onKernelController(ControllerEvent $event)
132132
{
133133
$controller = $event->getController();
134134

@@ -188,7 +188,7 @@ For example, take the ``TokenSubscriber`` from the previous example and first
188188
record the authentication token inside the request attributes. This will
189189
serve as a basic flag that this request underwent token authentication::
190190

191-
public function onKernelController(FilterControllerEvent $event)
191+
public function onKernelController(ControllerEvent $event)
192192
{
193193
// ...
194194

@@ -208,9 +208,9 @@ This will look for the ``auth_token`` flag on the request object and set a custo
208208
header on the response if it's found::
209209

210210
// add the new use statement at the top of your file
211-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
211+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
212212

213-
public function onKernelResponse(FilterResponseEvent $event)
213+
public function onKernelResponse(ResponseEvent $event)
214214
{
215215
// check to see if onKernelController marked this as a token "auth'ed" request
216216
if (!$token = $event->getRequest()->attributes->get('auth_token')) {

profiler.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,11 @@ production. To do that, create an :doc:`event subscriber </event_dispatcher>`
197197
and listen to the :ref:`kernel.response<component-http-kernel-kernel-response>`
198198
event::
199199

200-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
200+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
201201

202202
// ...
203203

204-
public function onKernelResponse(FilterResponseEvent $event)
204+
public function onKernelResponse(ResponseEvent $event)
205205
{
206206
if (!$this->getKernel()->isDebug()) {
207207
return;

reference/events.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ following information:
2828
``kernel.request``
2929
~~~~~~~~~~~~~~~~~~
3030

31-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent`
31+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent`
3232

3333
This event is dispatched very early in Symfony, before the controller is
3434
determined. It's useful to add information to the Request or return a Response
@@ -48,16 +48,16 @@ their priorities:
4848
``kernel.controller``
4949
~~~~~~~~~~~~~~~~~~~~~
5050

51-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerEvent`
51+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerEvent`
5252

5353
This event is dispatched after the controller to be executed has been resolved
5454
but before executing it. It's useful to initialize things later needed by the
5555
controller, such as `param converters`_, and even to change the controller
5656
entirely::
5757

58-
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
58+
use Symfony\Component\HttpKernel\Event\ControllerEvent;
5959

60-
public function onKernelController(FilterControllerEvent $event)
60+
public function onKernelController(ControllerEvent $event)
6161
{
6262
// ...
6363

@@ -79,15 +79,15 @@ their priorities:
7979
``kernel.controller_arguments``
8080
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8181

82-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterControllerArgumentsEvent`
82+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\ControllerArgumentsEvent`
8383

8484
This event is dispatched just before a controller is called. It's useful to
8585
configure the arguments that are going to be passed to the controller.
8686
Typically, this is used to map URL routing parameters to their corresponding
8787
named arguments; or pass the current request when the ``Request`` type-hint is
8888
found::
8989

90-
public function onKernelControllerArguments(FilterControllerArgumentsEvent $event)
90+
public function onKernelControllerArguments(ControllerArgumentsEvent $event)
9191
{
9292
// ...
9393

@@ -109,17 +109,17 @@ their priorities:
109109
``kernel.view``
110110
~~~~~~~~~~~~~~~
111111

112-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForControllerResultEvent`
112+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\ViewEvent`
113113

114114
This event is dispatched after the controller has been executed but *only* if
115115
the controller does *not* return a :class:`Symfony\\Component\\HttpFoundation\\Response`
116116
object. It's useful to transform the returned value (e.g. a string with some
117117
HTML contents) into the ``Response`` object needed by Symfony::
118118

119119
use Symfony\Component\HttpFoundation\Response;
120-
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
120+
use Symfony\Component\HttpKernel\Event\ViewEvent;
121121

122-
public function onKernelView(GetResponseForControllerResultEvent $event)
122+
public function onKernelView(ViewEvent $event)
123123
{
124124
$value = $event->getControllerResult();
125125
$response = new Response();
@@ -143,13 +143,13 @@ their priorities:
143143
``kernel.response``
144144
~~~~~~~~~~~~~~~~~~~
145145

146-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\FilterResponseEvent`
146+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\ResponseEvent`
147147

148148
This event is dispatched after the controller or any ``kernel.view`` listener
149149
returns a ``Response`` object. It's useful to modify or replace the response
150150
before sending it back (e.g. add/modify HTTP headers, add cookies, etc.)::
151151

152-
public function onKernelResponse(FilterResponseEvent $event)
152+
public function onKernelResponse(ResponseEvent $event)
153153
{
154154
$response = $event->getResponse();
155155

@@ -196,7 +196,7 @@ their priorities:
196196
``kernel.terminate``
197197
~~~~~~~~~~~~~~~~~~~~
198198

199-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\PostResponseEvent`
199+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\TerminateEvent`
200200

201201
This event is dispatched after the response has been sent (after the execution
202202
of the :method:`Symfony\\Component\\HttpKernel\\HttpKernel::handle` method).
@@ -219,16 +219,16 @@ their priorities:
219219
``kernel.exception``
220220
~~~~~~~~~~~~~~~~~~~~
221221

222-
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseForExceptionEvent`
222+
**Event Class**: :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent`
223223

224224
This event is dispatched as soon as an error occurs during the handling of the
225225
HTTP request. It's useful to recover from errors or modify the exception details
226226
sent as response::
227227

228228
use Symfony\Component\HttpFoundation\Response;
229-
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
229+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
230230

231-
public function onKernelException(GetResponseForExceptionEvent $event)
231+
public function onKernelException(ExceptionEvent $event)
232232
{
233233
$exception = $event->getException();
234234
$response = new Response();
@@ -265,7 +265,7 @@ response:
265265

266266
If you want to overwrite the status code of the exception response, which
267267
you should not without a good reason, call
268-
``GetResponseForExceptionEvent::allowCustomResponseCode()`` first and then
268+
``ExceptionEvent::allowCustomResponseCode()`` first and then
269269
set the status code on the response::
270270

271271
$event->allowCustomResponseCode();

security/custom_authentication_provider.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ is responsible for fielding requests to the firewall and calling the authenticat
100100
provider. A listener must be an instance of
101101
:class:`Symfony\\Component\\Security\\Http\\Firewall\\ListenerInterface`.
102102
A security listener should handle the
103-
:class:`Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent` event, and
103+
:class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent` event, and
104104
set an authenticated token in the token storage if successful::
105105

106106
// src/Security/Firewall/WsseListener.php
107107
namespace App\Security\Firewall;
108108

109109
use App\Security\Authentication\Token\WsseUserToken;
110110
use Symfony\Component\HttpFoundation\Response;
111-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
111+
use Symfony\Component\HttpKernel\Event\RequestEvent;
112112
use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface;
113113
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
114114
use Symfony\Component\Security\Core\Exception\AuthenticationException;
@@ -125,7 +125,7 @@ set an authenticated token in the token storage if successful::
125125
$this->authenticationManager = $authenticationManager;
126126
}
127127

128-
public function handle(GetResponseEvent $event)
128+
public function handle(RequestEvent $event)
129129
{
130130
$request = $event->getRequest();
131131

service_container/3.3-di-changes.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,12 +373,12 @@ create the class::
373373
// ...
374374

375375
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
376-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
376+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
377377
use Symfony\Component\HttpKernel\KernelEvents;
378378

379379
class SetHeaderSusbcriber implements EventSubscriberInterface
380380
{
381-
public function onKernelResponse(FilterResponseEvent $event)
381+
public function onKernelResponse(ResponseEvent $event)
382382
{
383383
$event->getResponse()->headers->set('X-SYMFONY-3.3', 'Less config');
384384
}

translation/locale.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ To set the user's locale, you may want to create a custom event listener so
1818
that it's set before any other parts of the system (i.e. the translator) need
1919
it::
2020

21-
public function onKernelRequest(GetResponseEvent $event)
21+
public function onKernelRequest(RequestEvent $event)
2222
{
2323
$request = $event->getRequest();
2424

0 commit comments

Comments
 (0)