Skip to content

Instantly share code, notes, and snippets.

@franzose
Created January 21, 2018 03:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franzose/8b7f1f054e2fb43aaa5e84135cde07bc to your computer and use it in GitHub Desktop.
Save franzose/8b7f1f054e2fb43aaa5e84135cde07bc to your computer and use it in GitHub Desktop.
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