diff --git a/src/Twig/AppExtension.php b/src/Twig/AppExtension.php index 6389e00..e7dcb37 100644 --- a/src/Twig/AppExtension.php +++ b/src/Twig/AppExtension.php @@ -31,6 +31,7 @@ class AppExtension extends AbstractExtension return [ new TwigFunction('icon', [AppRuntime::class, 'renderIcon'], ['needs_environment' => true, 'is_safe' => ['html']]), new TwigFunction('is_current_route', [AppRuntime::class, 'isCurrentRoute']), + new TwigFunction('is_maintenance_mode', [AppRuntime::class, 'isMaintenanceMode']), new TwigFunction('return_url', [AppRuntime::class, 'getEncodedReturnUrl']), new TwigFunction('forwarded_return_url', [AppRuntime::class, 'getForwardedReturnUrl']), new TwigFunction('qa_attribute', [AppRuntime::class, 'renderQaAttribute'], ['is_safe' => ['html']]), diff --git a/src/Twig/AppRuntime.php b/src/Twig/AppRuntime.php index 8d1acc0..13d39b7 100644 --- a/src/Twig/AppRuntime.php +++ b/src/Twig/AppRuntime.php @@ -180,6 +180,14 @@ class AppRuntime implements RuntimeExtensionInterface return $requestedRoute === $route; } + /** + * The attribute is set by MaintenanceModeListener, on the ip whitelist branch only. + */ + public function isMaintenanceMode(): bool + { + return true === $this->requestStack->getMainRequest()?->attributes->get('_maintenance_mode_allowed'); + } + public function getEncodedReturnUrl(): string { $masterRequest = $this->requestStack->getMainRequest(); diff --git a/templates/_partials/_maintenance_banner.html.twig b/templates/_partials/_maintenance_banner.html.twig new file mode 100644 index 0000000..3b0a70b --- /dev/null +++ b/templates/_partials/_maintenance_banner.html.twig @@ -0,0 +1,6 @@ +{% if is_maintenance_mode() %} +