parent
eecf0689a6
commit
ae375b8738
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Controller;
|
||||||
|
|
||||||
|
require_once __DIR__ . "/../react-display.php";
|
||||||
|
use App\Gateway\FormResultGateway;
|
||||||
|
use \Twig\Environment;
|
||||||
|
use Twig\Error\LoaderError;
|
||||||
|
use Twig\Error\RuntimeError;
|
||||||
|
use Twig\Error\SyntaxError;
|
||||||
|
|
||||||
|
class ErrorController
|
||||||
|
{
|
||||||
|
private FormResultGateway $gateway;
|
||||||
|
private Environment $twig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param FormResultGateway $gateway
|
||||||
|
*/
|
||||||
|
public function __construct(FormResultGateway $gateway, Environment $twig)
|
||||||
|
{
|
||||||
|
$this->gateway = $gateway;
|
||||||
|
$this->twig = $twig;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function displayError($error) {
|
||||||
|
$error = array("error" => $error);
|
||||||
|
try {
|
||||||
|
echo $this->twig->render('error.html.twig', $error);
|
||||||
|
} catch (LoaderError | RuntimeError | SyntaxError $e) {
|
||||||
|
echo "Twig error: $e";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,23 +0,0 @@
|
|||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<title>Error</title>
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
|
|
||||||
<h1>IQBall</h1>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
if (isset($error)) {
|
|
||||||
if($error == "error404"){
|
|
||||||
echo "<h1>Erreur 404</h1>";
|
|
||||||
echo "<h3>Cette page n'existe pas</h3>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<button onclick="location.href='/'" type="button">Retour à la page d'accueil</button>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -0,0 +1,29 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Error</title>
|
||||||
|
|
||||||
|
{% block stylesheets %}
|
||||||
|
<style>
|
||||||
|
h1 { color: #da6110; text-align: center;}
|
||||||
|
h2 { text-align: center;}
|
||||||
|
.button { display: block; margin: 0 auto; cursor : pointer; background-color: white; color : black; text-align: center; font-size: 20px; border-radius: 12px; border : 2px solid #da6110}
|
||||||
|
.button:hover {background-color: #da6110}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>IQBall</h1>
|
||||||
|
|
||||||
|
{% if error == "404" %}
|
||||||
|
<h2>Erreur 404 : cette page n'existe pas</h2>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
<button class="button" onclick="location.href='/'" type="button">Retour à la page d'accueil</button>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in new issue