Symfony 3 -> onKernelException -> zmiana getDefaultLocale()

0

Witam,
Mam następujący problem:
W konfiguracji Symfony (v3) mam następujące ustawienia:

// app/config/config.yml
framework:
    translator: { fallbacks: ['%locale%'] }
    default_locale: pl
// app/config/config_ENV.yml
parameters:
    locale: pl

Routing wygląda następująco:

lang_homepage:
    path:     /{_locale}/
    defaults: { _controller: LangBundle:Default:index }
    requirements:
        _locale: pl|en

Po wywołaniu błędnego adresu URL przechwytuje Exception za pomocą ExceptionListener'a.
(jak na przykładzie: http://symfony.com/doc/current/event_dispatcher.html)

Problem polega na tym, że w Request w metodzie onKernelException składowe są następujące:
defaultLocale zawsze zwraca 'en' => potrzebuję tutaj defaultLocale z kernela (który jest normalnie wszędzie w requestach, a tylko w exceptionach jest 'en'...)
locale zawsze zwraca 'null' => potrzebuję tutaj '_locale' z adresu URL request'a (który jest normalnie wszędzie w requestach, a tylko w exceptionach jest null...)

0

Wydaje mi się, ze tutaj możemy mieć do czynienia z sytuacją, kiedy Twój exception uruchamiany jest wcześniej, niż translator. Spróbuj ustawić ręcznie priorytet uruchomienia na niższy (domyślnie jest 0).

The other optional tag attribute is called priority, which defaults to 0 and it controls the order in which listeners are executed (the highest the priority, the earlier a listener is executed). This is useful when you need to guarantee that one listener is executed before another. The priorities of the internal Symfony listeners usually range from -255 to 255 but your own listeners can use any positive or negative integer.

1 użytkowników online, w tym zalogowanych: 0, gości: 1