env = $env; $this->request = $request; } /** * Checks whether the request contains any flush indicators * * * @return null|bool flush or don't care */ protected function lookupRequest() { $request = $this->request; $getVar = array_key_exists('flush', $request->getVars()); $devBuild = $request->getURL() === 'dev/build'; // WARNING! // We specifically return `null` and not `false` here so that // it does not override other FlushDiscoverers return ($getVar || $devBuild) ? true : null; } /** * Checks for permission to flush * * Startup flush through a request is only allowed * to CLI or DEV modes for security reasons * * @return bool|null true for allow, false for denying, or null if don't care */ protected function isAllowed() { // WARNING! // We specifically return `null` and not `false` here so that // it does not override other FlushDiscoverers return (Environment::isCli() || $this->env === Kernel::DEV) ? true : null; } public function shouldFlush() { if (!$allowed = $this->isAllowed()) { return $allowed; } return $this->lookupRequest(); } }