src/Controller/UserController.php line 25

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use Symfony\Component\HttpFoundation\RedirectResponse;
  4. use Symfony\Component\HttpFoundation\Response;
  5. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  8. use Symfony\Component\HttpFoundation\Request;
  9. class UserController extends AbstractController
  10. {
  11.   private $session;
  12.   public function __construct(
  13.     SessionInterface $session
  14.   ) {
  15.     $this->session $session;
  16.   }
  17.   /**
  18.    * @Route("/", name="index", methods={"GET"}, priority=1)
  19.    */
  20.   public function index(Request $request)
  21.   {
  22.     if($this->session->get('user_id')) {
  23.       return new RedirectResponse($this->generateUrl('orders_list'));
  24.     }
  25.     return $this->render('link/signin.html.twig');
  26.   }
  27. }