security->isGranted('ROLE_USER')) { throw new AccessDeniedHttpException(); } $user = $this->security->getUser(); $command = UpdateProfileCommand::create($user, $this->notificationFlagManager); $editForm = $this->formFactory->create(UpdateProfileType::class, $command); $editForm->handleRequest($request); if ($editForm->isSubmitted() && $editForm->isValid()) { $this->updateProfileCommandHandler->updateProfile($user, $command); $this->entityManager->flush(); $session->getFlashBag()->add('success', $this->translator->trans('user.profile.Profile successfully updated!')); return new RedirectResponse($this->urlGenerator->generate('chill_main_user_profile')); } return new Response($this->twig->render('@ChillMain/User/profile.html.twig', [ 'user' => $user, 'form' => $editForm->createView(), ])); } }