public function switchLocaleAction(Request $request)
 {
     $this->guard->userIsLoggedIn();
     $this->logger->notice('User requested to switch locale');
     $returnUrl = $request->query->get('return-url');
     // Return URLs generated by us always include a path (ie. at least a forward slash)
     // @see https://github.com/symfony/symfony/blob/master/src/Symfony/Component/HttpFoundation/Request.php#L878
     $domain = $request->getSchemeAndHttpHost() . '/';
     if (strpos($returnUrl, $domain) !== 0) {
         $this->logger->error(sprintf('Illegal return-url ("%s") for redirection after changing locale, aborting request', $returnUrl));
         throw new BadRequestHttpException('Invalid return-url given');
     }
     $command = new ChangeLocaleCommand();
     $form = $this->formFactory->create('profile_switch_locale', $command, [])->handleRequest($request);
     $this->logger->notice(sprintf('Switching locale from "%s" to "%s"', $request->getLocale(), $command->newLocale));
     if ($form->isValid()) {
         $this->userService->changeLocale($command);
         $this->flashBag->add('success', 'profile.locale.locale_change_success');
         $this->logger->notice(sprintf('Successfully switched locale from "%s" to "%s"', $request->getLocale(), $command->newLocale));
     } else {
         $this->flashBag->add('error', 'profile.locale.locale_change_fail');
         $this->logger->error('Locale not switched: the switch locale form contained invalid data');
     }
     return new RedirectResponse($returnUrl);
 }
 /**
  * @return Response
  */
 public function overviewAction()
 {
     $this->guard->userIsLoggedIn();
     $this->logger->notice('Showing My Profile page');
     $user = $this->userService->getUser();
     return new Response($this->templateEngine->render('OpenConextProfileBundle:MyProfile:overview.html.twig', ['user' => $user]));
 }
 public function sendAttributeSupportMail()
 {
     $user = $this->userService->getUser();
     $body = $this->templateEngine->render('OpenConextProfileBundle:AttributeSupport:email.html.twig', ['attributes' => $user->getAttributes()]);
     /** @var Message $message */
     $message = $this->mailer->createMessage();
     $message->setFrom($this->mailFrom->getEmailAddress())->setTo($this->mailTo->getEmailAddress())->setSubject(sprintf('Personal debug info of %s', $user->getId()))->setBody($body, 'text/html', 'utf-8');
     $this->mailer->send($message);
 }
 public function overviewAction()
 {
     $this->guard->userIsLoggedIn();
     $attributeSupportMailForm = $this->formFactory->create('profile_attribute_support_mail', null, ['action' => $this->urlGenerator->generate('profile.attribute_support_send_mail')]);
     return new Response($this->templateEngine->render('OpenConextProfileBundle:AttributeSupport:overview.html.twig', ['attributes' => $this->userService->getUser()->getAttributes(), 'attributeSupportMailForm' => $attributeSupportMailForm->createView()]));
 }