public onKernelRequest ( |
||
$event |
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
// Skip the check on localhost
if (in_array($request->getClientIp(), $this->localIps)) {
return;
}
// The document root does not contain /web
if ('/web' !== substr($request->getBasePath(), -4)) {
return;
}
throw new InsecureInstallationException('Your installation is not secure. Please set the document root to the /web subfolder.');
}
/** * Tests the onKernelRequest() method with a secure document root. */ public function testOnKernelRequestWithSecureDocumentRoot() { $kernel = $this->mockKernel(); $request = $this->getRequestObject(); $request->server->set('REQUEST_URI', '/app_dev.php?do=test'); $request->server->set('SCRIPT_FILENAME', $this->getRootDir() . '/app_dev.php'); $event = new GetResponseEvent($kernel, $request, Kernel::MASTER_REQUEST); $listener = new InsecureInstallationListener(); $listener->onKernelRequest($event); }