Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Maintenance Mode try
<?php
public function onKernelRequest(GetResponseEvent $event)
{
if (!$event->isMasterRequest()) {
return;
}
if ($this->isMaintenanceMode() && !$this->isUserAdmin()) {
$event->setResponse($this->renderMaintenanceView());
}
}
private function isMaintenanceMode()
{
$setting = $this->settings->findByCode('maintenance_mode');
return null !== $setting && 1 === (int) $setting->getValue();
}
private function isUserAdmin()
{
return $this->checker->isGranted(AdminUserInterface::DEFAULT_ADMIN_ROLE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment