問題我有,當用戶更改登錄頁面中的語言時 - 它工作,但用戶登錄後 - 它又恢復爲默認值。如何使登錄前保持選定的語言用戶可以保持登錄狀態? 我試過在stackoverflow上查找這個,但無法找到任何工作的結果。Symfony3登錄後保留區域設置
security.yml:
<ul class="top-menu-list top-menu-languages">
<li><a href="{{ path(app.request.attributes.get('_route'), app.request.query.all|merge({'_locale': 'lt'})) }}">LT</a></li>
<li><a href="{{ path(app.request.attributes.get('_route'), app.request.query.all|merge({'_locale': 'en'})) }}">EN</a></li>
<li><a href="{{ path(app.request.attributes.get('_route'), app.request.query.all|merge({'_locale': 'ru'})) }}">RU</a></li>
</ul>
任何意見或E:
security:
encoders:
AppBundle\Entity\User:
algorithm: bcrypt
role_hierarchy:
ROLE_ADMIN: ROLE_PREMIUM
ROLE_PREMIUM: ROLE_USER
providers:
our_db_provider:
entity:
class: AppBundle:User
property: email
in_memory:
memory: ~
firewalls:
# disables authentication for assets and the profiler, adapt it according to your needs
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
main:
anonymous: ~
form_login:
#galima nurodyti kur nukreipia loginas
login_path: login
check_path: login
csrf_token_generator: security.csrf.token_manager
logout:
path: /logout
pattern: ^/
http_basic: ~
provider: our_db_provider
access_denied_url: homepage
的routing.yml
app:
resource: "@AppBundle/Controller/"
type: annotation
prefix: /{_locale}
requirements:
_locale: lt|en|ru
root:
path:/
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /%locale%/
permanent: true
login:
path: /{_locale}/login
defaults: { _controller: AppBundle:Security:login }
requirements:
_method: GET
_locale: lt|en|ru
logout:
path: /logout
defaults:
_controller: FrameworkBundle:Redirect:urlRedirect
path: /{_locale}/login
permanent: true
register:
path: /{_locale}/register
defaults: { _controller: AppBundle:Registration:register }
requirements:
_method: GET
_locale: lt|en|ru
語言的改變xamples將不勝感激!
使用用戶登錄監聽器,並重定向到引用者:http://stackoverflow.com/questions/11180351/symfony2-after-successful-login-event-perform-set-of-動作 – COil
整個示例很久以前不推薦使用... – JustinasT
http://symfony.com/doc/current/components/security/authentication.html#authentication-events – COil