/** * Set the right locale via context. * * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if (!$request->hasPreviousSession()) { return; } $request->setLocale($this->localeContext->getCurrentLocale() ?: $this->localeContext->getDefaultLocale()); }
function it_converts_locales_code_to_name(LocaleContextInterface $localeContext) { $localeContext->getCurrentLocale()->shouldBeCalled()->willReturn('en_US'); $this->convertToName('fr_FR')->shouldReturn('French (France)'); }
/** * {@inheritdoc} */ public function getLocaleCode() { return $this->localeContext->getCurrentLocale(); }
function it_gets_current_locale_code_from_context(LocaleContextInterface $localeContext) { $localeContext->getCurrentLocale()->willReturn('en_US'); $this->getLocaleCode()->shouldReturn('en_US'); }