public function register(Application $app) { $app['config'] = $app->share(function ($app) { $config = new Config($app); $config->initialize(); return $config; }); $app['config.environment'] = $app->share(function ($app) { $appPath = $app['resources']->getPath('app'); $viewPath = $app['resources']->getPath('view'); $environment = new Environment($appPath, $viewPath, $app['cache'], $app['extend.action'], Bolt\Version::VERSION); return $environment; }); $app['config.validator'] = $app->share(function ($app) { $validator = new ConfigValidator($app['controller.exception'], $app['config'], $app['resources']); return $validator; }); $app['config.listener'] = $app->share(function ($app) { return new ConfigListener($app); }); if (!isset($app['config.pre_boot'])) { $this->preBoot($app['resources']); $app['config.pre_boot'] = true; } }
protected function doDatabaseSqliteCheck(Controller\Exception $exceptionController, array $dbConfig) { if (extension_loaded('pdo_sqlite') === false) { return $exceptionController->databaseDriver('missing', 'SQLite', 'pdo_sqlite'); } // If in-memory connection, skip path checks if (isset($dbConfig['memory']) && $dbConfig['memory'] === true) { return null; } $fs = new Filesystem(); $file = $dbConfig['path']; // If the file is present, make sure it is writable if ($fs->exists($file)) { try { $fs->touch($file); } catch (IOException $e) { return $exceptionController->databasePath('file', $file, 'is not writable'); } return null; } // If the file isn't present, make sure the directory // exists and is writable so the file can be created $dir = dirname($file); if (!$fs->exists($dir)) { // At this point, it is possible that the site has been moved and // the configured Sqlite database file path is no longer relevant // to the site's root path $cacheJson = $this->resourceManager->getPath('cache/config-cache.json'); if ($fs->exists($cacheJson)) { $fs->remove($cacheJson); $this->config->initialize(); if (!$fs->exists($dir)) { return $exceptionController->databasePath('folder', $dir, 'does not exist'); } } else { return $exceptionController->databasePath('folder', $dir, 'does not exist'); } } try { $fs->touch($dir); } catch (IOException $e) { return $exceptionController->databasePath('folder', $dir, 'is not writable'); } return null; }