ProfilController.php 931 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Controller;
  3. use Doctrine\ORM\EntityManagerInterface;
  4. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  5. use Symfony\Component\HttpFoundation\Request;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. class ProfilController extends AbstractController
  8. {
  9. /**
  10. * @Route("/profil/", name="user_profil")
  11. */
  12. public function monProfilAction(Request $request, EntityManagerInterface $em)
  13. {
  14. $user = $this->getUser();
  15. $form = $this->createForm('App\Form\UserEditProfilType', $user);
  16. $form->handleRequest($request);
  17. if ($form->isSubmitted() && $form->isValid())
  18. {
  19. $user = $form->getData();
  20. $em->flush();
  21. $this->addFlash('success', "Votre profil a été modifié");
  22. }
  23. return $this->render('profil/monprofil.html.twig', array (
  24. 'form' => $form->createView()
  25. ));
  26. }
  27. }