<?php
namespace App\Controller\Web;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use App\Form\Type\User\UserFirstConnexionType;
/**
* Class HomeController
*/
class HomeController extends Controller
{
/**
* @Route("/", name="web_home", options={"expose"=true})
*/
public function index()
{
return $this->render('web/dash/index.html.twig', [
]);
}
/**
* @Route("/policy", name="app_policy", options={"expose"=true})
*/
public function policy()
{
return $this->render('web/dash/policy.html.twig', [
]);
}
/**
* @Route("/first-connexion", name="web_first_connexion", options={"expose"=true})
*/
public function changeFirstConnexionAction(Request $request)
{
/** @var User $user */
$user = $this->getUser();
$form = $this->createForm(UserFirstConnexionType::class, $user);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$user->setFirstConnect(false);
$usermanager = $this->get('fos_user.user_manager');
$usermanager->updateUser($user);
return $this->redirectToRoute('web_home');
}
return $this->render('web/login/first-connexion.html.twig', [
'form' => $form->createView(),
]);
}
}