1
0
mirror of https://github.com/flarum/core.git synced 2025-08-02 22:47:33 +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 * @var array
*/ */
protected $config; protected $config = [];
protected $extenders = []; protected $extenders = [];
@@ -73,10 +73,6 @@ class Site
{ {
$this->basePath = getcwd(); $this->basePath = getcwd();
$this->publicPath = $this->basePath; $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; $this->basePath = $basePath;
if (file_exists($file = $this->basePath.'/config.php')) {
$this->config = include $file;
}
return $this; return $this;
} }
@@ -135,6 +127,15 @@ class Site
return $this; 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 * @return Application
*/ */
@@ -153,7 +154,7 @@ class Site
} }
$app->instance('env', 'production'); $app->instance('env', 'production');
$app->instance('flarum.config', $this->config); $app->instance('flarum.config', $this->getConfig());
$app->instance('config', $config = $this->getIlluminateConfig($app)); $app->instance('config', $config = $this->getIlluminateConfig($app));
$this->registerLogger($app); $this->registerLogger($app);