src/Controller/ErrorController.php line 30

  1. <?php
  2. namespace App\Controller;
  3. use App\Service\ASRedis;
  4. use Symfony\Component\HttpFoundation\Request;
  5. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  6. use Symfony\Component\Routing\Annotation\Route;
  7. use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
  8. use Throwable;
  9. /**
  10.  * Class ErrorController
  11.  * @package App\Controller
  12.  * @Route("/error")
  13.  */
  14. class ErrorController extends AbstractController
  15. {
  16.     private $asRedis;
  17.     public function __construct(ASRedis $asRedis)
  18.     {
  19.         $this->asRedis $asRedis;
  20.     }
  21.     /**
  22.      * @param Request $request
  23.      * @return \Symfony\Component\HttpFoundation\Response
  24.      * @Route("/", name="error_exception", methods={"GET"})
  25.      */
  26.     public function show(Request $request)
  27.     {
  28.         $code $request->query->get('code');
  29.         $is_authenticated $request->query->get('is_authenticated');
  30.         $template '';
  31.         switch ($code) {
  32.             case "2":
  33.                 $template "errors/error403.html.twig";
  34.                 break;
  35.             case "3":
  36.                 $template "errors/error404.html.twig";
  37.                 break;
  38.             case "4":
  39.                 $template "errors/worker_error403.html.twig";
  40.                 break;
  41.             case "5":
  42.                 $template "errors/session_expired.html.twig";
  43.                 break;
  44.         }
  45.         return $this->render($template, ['is_authenticated' => $is_authenticated]);
  46.     }
  47.     /**
  48.      * @param Request $request
  49.      * @return \Symfony\Component\HttpFoundation\Response
  50.      * @Route("/cise", name="check_if_session_expired", methods={"GET"})
  51.      */
  52.     public function checkIfSessionExpired(Request $request)
  53.     {
  54.         $redisValidation $this->asRedis->validateASUserRedis();
  55.         return $this->json($this->asRedis->isValidASUserRedis($redisValidation) === true);
  56.     }
  57.     /**
  58.      * @param Request $request
  59.      * @Route("/vf", name="verification_fail", methods={"GET"})
  60.      */
  61.     public function virificationFail(Request $request)
  62.     {
  63.         return $this->render("errors/error_verification.html.twig", ['is_authenticated' => false]);
  64.     }
  65.     // *** leave comment out for now so error will display in the layout so dev can fix it easily... ***
  66.     // public function error(Throwable $exception)
  67.     // {
  68.     //     $code = '';
  69.     //     if ($exception instanceof HttpExceptionInterface) {
  70.     //         $code = $exception->getStatusCode();
  71.     //     }
  72.     //         return  $code !== 404 ? $this->render('index.html.twig') :
  73.     // $this->render('errors/error404.html.twig', array());
  74.     // }
  75. }