src/Controller/Web/HomeController.php line 20

Open in your IDE?
  1. <?php
  2. namespace App\Controller\Web;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  5. use Symfony\Component\HttpFoundation\RedirectResponse;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use App\Form\Type\User\UserFirstConnexionType;
  8. /**
  9.  * Class HomeController
  10.  */
  11. class HomeController extends Controller
  12. {
  13.     /**
  14.      * @Route("/", name="web_home", options={"expose"=true})
  15.      */
  16.     public function index()
  17.     {
  18.         return $this->render('web/dash/index.html.twig', [
  19.         ]);
  20.     }
  21.     /**
  22.      * @Route("/policy", name="app_policy", options={"expose"=true})
  23.      */
  24.     public function policy()
  25.     {
  26.         return $this->render('web/dash/policy.html.twig', [
  27.         ]);
  28.     }
  29.     /**
  30.      * @Route("/first-connexion", name="web_first_connexion", options={"expose"=true})
  31.      */
  32.     public function changeFirstConnexionAction(Request $request)
  33.     {
  34.         /** @var User $user */
  35.         $user $this->getUser();
  36.         $form $this->createForm(UserFirstConnexionType::class, $user);
  37.         $form->handleRequest($request);
  38.         if ($form->isSubmitted() && $form->isValid()) {
  39.             $user->setFirstConnect(false);
  40.             $usermanager $this->get('fos_user.user_manager');
  41.             $usermanager->updateUser($user);
  42.             return $this->redirectToRoute('web_home');
  43.         }
  44.         return $this->render('web/login/first-connexion.html.twig', [
  45.                     'form' => $form->createView(),
  46.         ]);
  47.     }
  48. }