コード例 #1
0
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->hasPreviousSession()) {
         return;
     }
     $request->setLocale($this->localeService->getLocale()->getLocale());
 }
コード例 #2
0
 /**
  * @return User
  */
 public function getUser()
 {
     $user = $this->userRepository->findUser();
     if ($user) {
         return $user;
     }
     $user = new User($this->authenticatedUserProvider->getCurrentUser(), $this->localeService->getLocale());
     $user = $this->enrichUserWithSupportContactEmail($user);
     $this->userRepository->save($user);
     return $user;
 }
コード例 #3
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $availableLocales = $this->localeService->getAvailableLocales();
     $localeChoices = $this->formatLocaleChoices($availableLocales);
     $builder->setAction($this->urlGenerator->generate('profile.locale_switch_locale', ['return-url' => $options['return_url']]))->add('newLocale', 'choice', ['choices' => $localeChoices, 'data' => $this->localeService->getLocale()->getLocale(), 'attr' => ['data-locale-options' => '']])->add('changeLocale', 'submit', ['label' => 'profile.locale.choose_locale']);
 }