Returns the site maintenance page if the site is offline.
\Symfony\Component\HttpKernel\Event\GetResponseEvent $event: The event to process.
public function onKernelRequestMaintenance(GetResponseEvent $event) {
$request = $event
->getRequest();
$response = $event
->getResponse();
// Continue if the site is online and the response is not a redirection.
if ($request->attributes
->get('_maintenance') != MENU_SITE_ONLINE && !$response instanceof RedirectResponse) {
// Deliver the 503 page.
drupal_maintenance_theme();
drupal_set_title(t('Site under maintenance'));
$content = theme('maintenance_page', array(
'content' => filter_xss_admin(t(config('system.maintenance')
->get('message'), array(
'@site' => config('system.site')
->get('name'),
))),
));
$response = new Response('Service unavailable', 503);
$response
->setContent($content);
$event
->setResponse($response);
}
}