1
0
mirror of https://github.com/flarum/core.git synced 2025-07-31 05:30:38 +02:00

DRY up loading of config

This commit is contained in:
Franz Liedke
2017-12-19 23:16:06 +01:00
parent e9da1ba2f5
commit bfd98e3371

View File

@@ -65,7 +65,7 @@ class Site
/**
* @var array
*/
protected $config;
protected $config = [];
protected $extenders = [];
@@ -73,10 +73,6 @@ class Site
{
$this->basePath = getcwd();
$this->publicPath = $this->basePath;
if (file_exists($file = $this->basePath.'/config.php')) {
$this->config = include $file;
}
}
/**
@@ -95,10 +91,6 @@ class Site
{
$this->basePath = $basePath;
if (file_exists($file = $this->basePath.'/config.php')) {
$this->config = include $file;
}
return $this;
}
@@ -135,6 +127,15 @@ class Site
return $this;
}
protected function getConfig()
{
if (empty($this->config) && file_exists($file = $this->basePath.'/config.php')) {
$this->config = include $file;
}
return $this->config;
}
/**
* @return Application
*/
@@ -153,7 +154,7 @@ class Site
}
$app->instance('env', 'production');
$app->instance('flarum.config', $this->config);
$app->instance('flarum.config', $this->getConfig());
$app->instance('config', $config = $this->getIlluminateConfig($app));
$this->registerLogger($app);