-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
85 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
# Set to 1 on production to disable watermarks and hints on webpages | ||
IS_PRODUCTIVE=0 | ||
|
||
# Set to 1 to enable maintenance mode, where no frontend is available (but backend login is still possible) | ||
MAINTENANCE_MODE=0 | ||
|
||
SUPPORT_EMAIL=[email protected] | ||
HHV_EMAIL=[email protected] | ||
# The email where the forms get sent to, when two stura financers confirmed a payment order | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
|
||
namespace App\EventListener; | ||
|
||
use Symfony\Component\DependencyInjection\Attribute\Autowire; | ||
use Symfony\Component\EventDispatcher\Attribute\AsEventListener; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Event\RequestEvent; | ||
use Twig\Environment; | ||
|
||
#[AsEventListener] | ||
final class MaintenanceModeListener | ||
{ | ||
|
||
public const EXLUDED_PATHS = [ | ||
'/admin', | ||
'/login', | ||
'/logout', | ||
'/2fa', | ||
'/_wdt', | ||
'/_profiler', | ||
]; | ||
|
||
public function __construct(private Environment $twig, | ||
#[Autowire(env: 'bool:MAINTENANCE_MODE')] | ||
private readonly bool $enabled = false) | ||
{ | ||
|
||
} | ||
|
||
public function __invoke(RequestEvent $event): void | ||
{ | ||
if (!$this->enabled) { | ||
return; | ||
} | ||
|
||
//Exclude certain paths from maintenance mode | ||
$path = $event->getRequest()->getPathInfo(); | ||
foreach (self::EXLUDED_PATHS as $excludedPath) { | ||
if (str_starts_with($path, $excludedPath)) { | ||
return; | ||
} | ||
} | ||
|
||
$response = new Response($this->twig->render('maintenance.html.twig'), Response::HTTP_SERVICE_UNAVAILABLE); | ||
|
||
$event->setResponse($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html lang="{{ app.request.locale }}"> | ||
<head> | ||
<!-- Required meta tags --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
|
||
<style> | ||
body { text-align: center; padding: 150px; } | ||
h1 { font-size: 50px; } | ||
body { font: 20px Helvetica, sans-serif; color: #333; } | ||
article { display: block; text-align: left; width: 650px; margin: 0 auto; } | ||
a { color: #dc8100; text-decoration: none; } | ||
a:hover { color: #333; text-decoration: none; } | ||
</style> | ||
|
||
<title>Wartungsmodus</title> | ||
</head> | ||
<body> | ||
<h1>Wartungsmodus</h1> | ||
<div> | ||
<p>Wir führen gerade Wartungsarbeiten durch. Versuche es bitte später erneut!</p> | ||
<p>— Admin</p> | ||
</div> | ||
|
||
<div style="position: fixed; bottom: 5em;"> | ||
<hr> | ||
<p><a href="{{ path("app_login") }}">Backend Login</a></p> | ||
</div> | ||
</body> |