@@ -121,7 +121,7 @@ want to be used as the locale for the given user. In order to achieve the wanted
121
121
configuration, you can set the locale which is defined for the user to the session right
122
122
after the login. Fortunately, you can hook into the login process and update the user's
123
123
session before the redirect to the first page. For this you need an event listener for the
124
- ``security.interactive_login `` event.
124
+ ``security.interactive_login `` event:
125
125
126
126
.. code-block :: php
127
127
@@ -170,12 +170,13 @@ Then register the listener:
170
170
services :
171
171
app.user_locale_listener :
172
172
class : AppBundle\EventListener\UserLocaleListener
173
+ arguments : [@session]
173
174
tags :
174
175
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
175
176
176
177
.. code-block :: xml
177
178
178
- <!-- app/config/config .xml -->
179
+ <!-- app/config/services .xml -->
179
180
<?xml version =" 1.0" encoding =" UTF-8" ?>
180
181
<container xmlns =" http://symfony.com/schema/dic/services"
181
182
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -186,6 +187,8 @@ Then register the listener:
186
187
<service id =" app.user_locale_listener"
187
188
class =" AppBundle\EventListener\UserLocaleListener" >
188
189
190
+ <argument type =" service" id =" session" />
191
+
189
192
<tag name =" kernel.event_listener"
190
193
event =" security.interactive_login"
191
194
method =" onInteractiveLogin" />
@@ -198,8 +201,11 @@ Then register the listener:
198
201
// app/config/services.php
199
202
$container
200
203
->register('app.user_locale_listener', 'AppBundle\EventListener\UserLocaleListener')
201
- ->addTag('kernel.event_listener', array('event' => 'security.interactive_login', 'method' => 'onInteractiveLogin'))
202
- ;
204
+ ->addArgument('session')
205
+ ->addTag(
206
+ 'kernel.event_listener',
207
+ array('event' => 'security.interactive_login', 'method' => 'onInteractiveLogin'
208
+ );
203
209
204
210
.. caution ::
205
211
0 commit comments