src/Controller/ErrorController.php line 30
<?php
namespace App\Controller;
use App\Service\ASRedis;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Throwable;
/**
* Class ErrorController
* @package App\Controller
* @Route("/error")
*/
class ErrorController extends AbstractController
{
private $asRedis;
public function __construct(ASRedis $asRedis)
{
$this->asRedis = $asRedis;
}
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
* @Route("/", name="error_exception", methods={"GET"})
*/
public function show(Request $request)
{
$code = $request->query->get('code');
$is_authenticated = $request->query->get('is_authenticated');
$template = '';
switch ($code) {
case "2":
$template = "errors/error403.html.twig";
break;
case "3":
$template = "errors/error404.html.twig";
break;
case "4":
$template = "errors/worker_error403.html.twig";
break;
case "5":
$template = "errors/session_expired.html.twig";
break;
}
return $this->render($template, ['is_authenticated' => $is_authenticated]);
}
/**
* @param Request $request
* @return \Symfony\Component\HttpFoundation\Response
* @Route("/cise", name="check_if_session_expired", methods={"GET"})
*/
public function checkIfSessionExpired(Request $request)
{
$redisValidation = $this->asRedis->validateASUserRedis();
return $this->json($this->asRedis->isValidASUserRedis($redisValidation) === true);
}
/**
* @param Request $request
* @Route("/vf", name="verification_fail", methods={"GET"})
*/
public function virificationFail(Request $request)
{
return $this->render("errors/error_verification.html.twig", ['is_authenticated' => false]);
}
// *** leave comment out for now so error will display in the layout so dev can fix it easily... ***
// public function error(Throwable $exception)
// {
// $code = '';
// if ($exception instanceof HttpExceptionInterface) {
// $code = $exception->getStatusCode();
// }
// return $code !== 404 ? $this->render('index.html.twig') :
// $this->render('errors/error404.html.twig', array());
// }
}