mirror of
https://github.com/flarum/framework.git
synced 2024-11-24 18:41:10 +08:00
DRY up loading of config
This commit is contained in:
parent
e9da1ba2f5
commit
bfd98e3371
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue
Block a user