@@ -121,7 +121,7 @@ want to be used as the locale for the given user. In order to achieve the wanted
121121configuration, you can set the locale which is defined for the user to the session right
122122after the login. Fortunately, you can hook into the login process and update the user's
123123session 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:
125125
126126.. code-block :: php
127127
@@ -170,12 +170,13 @@ Then register the listener:
170170 services :
171171 app.user_locale_listener :
172172 class : AppBundle\EventListener\UserLocaleListener
173+ arguments : [@session]
173174 tags :
174175 - { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
175176
176177 .. code-block :: xml
177178
178- <!-- app/config/config .xml -->
179+ <!-- app/config/services .xml -->
179180 <?xml version =" 1.0" encoding =" UTF-8" ?>
180181 <container xmlns =" http://symfony.com/schema/dic/services"
181182 xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
@@ -186,6 +187,8 @@ Then register the listener:
186187 <service id =" app.user_locale_listener"
187188 class =" AppBundle\EventListener\UserLocaleListener" >
188189
190+ <argument type =" service" id =" session" />
191+
189192 <tag name =" kernel.event_listener"
190193 event =" security.interactive_login"
191194 method =" onInteractiveLogin" />
@@ -198,8 +201,11 @@ Then register the listener:
198201 // app/config/services.php
199202 $container
200203 ->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+ );
203209
204210 .. caution ::
205211
0 commit comments