Skip to content

Update locale_sticky_session.rst #9440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
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
14 changes: 3 additions & 11 deletions session/locale_sticky_session.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ event::
// src/AppBundle/EventListener/UserLocaleListener.php
namespace AppBundle\EventListener;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Session\Session;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\SecurityEvents;
Expand Down Expand Up @@ -164,13 +163,6 @@ event::
$this->session->set('_locale', $user->getLocale());
}
}

public static function getSubscribedEvents()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this method is gone, we can also remove the use Symfony\Component\EventDispatcher\EventSubscriberInterface; at the top of this class. Thanks!

Copy link
Contributor Author

@bricelalu bricelalu Mar 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@javiereguiluz Thanks, it's done.

{
return array(
SecurityEvents::INTERACTIVE_LOGIN => array(array('onInteractiveLogin', 15)),
);
}
}

Then register the listener:
Expand All @@ -185,7 +177,7 @@ Then register the listener:
class: AppBundle\EventListener\UserLocaleListener
arguments: ['@session']
tags:
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin }
- { name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin, priority: 15 }

.. code-block:: xml

Expand All @@ -204,7 +196,7 @@ Then register the listener:

<tag name="kernel.event_listener"
event="security.interactive_login"
method="onInteractiveLogin" />
method="onInteractiveLogin" priority=15 />
</service>
</services>
</container>
Expand All @@ -220,7 +212,7 @@ Then register the listener:
->addArgument(new Reference('session'))
->addTag(
'kernel.event_listener',
array('event' => 'security.interactive_login', 'method' => 'onInteractiveLogin')
array('event' => 'security.interactive_login', 'method' => 'onInteractiveLogin', 'priority' => 15)
);

.. caution::
Expand Down