/** * Checks the web eligibility for Platform. If true, Platform * is safe to run in the web. * * @return bool * @throws \Symfony\Component\HttpKernel\Exception\HttpException */ public function checkRunningEligibility() { // If we're running in console, we're always fine to // run Platform except for testing. if ($this->app->runningInConsole()) { return $this->app->environment() !== 'testing'; } if ($this->isInstalled()) { // Now, let's check for database connectivity. If we have no // connectivity, the database connection is probably lost. // This means the service is in fact unavailable. try { $this->app['db']->connection(); return true; } catch (PDOException $e) { throw new HttpException(503, 'Database connection could not be established.'); } } // Check if the path is on the eligibility whitelist return in_array($this->app['request']->path(), $this->eligibilityWhitelist); }
/** * Returns flag on testing enviroment * * @return bool */ public function isTestingEnviroment() { return $this->app->runningInConsole() && $this->app->environment() === 'testing'; }