Created
January 21, 2018 03:04
-
-
Save franzose/8b7f1f054e2fb43aaa5e84135cde07bc to your computer and use it in GitHub Desktop.
Maintenance Mode try
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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