How do I check if the site is in maintenance mode?
-
07-01-2021 - |
Question
How do I call MaintenanceMode::applies(RouteMatchInterface $route_match)
from hook_theme_suggestions_page()
?
Solution
From a procedural hook you'll probably need to use something like:
use Drupal\Core\Routing\RouteMatch;
...
$maintenance_mode = \Drupal::service('maintenance_mode');
$route_match = RouteMatch::createFromRequest(\Drupal::request());
if ($maintenance_mode->applies($route_match)) {
// ...
}
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange