summaryrefslogtreecommitdiff
path: root/src/Config/ConfigServiceProvider.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Config/ConfigServiceProvider.php')
-rw-r--r--src/Config/ConfigServiceProvider.php21
1 files changed, 15 insertions, 6 deletions
diff --git a/src/Config/ConfigServiceProvider.php b/src/Config/ConfigServiceProvider.php
index 01b648df..9fbccd68 100644
--- a/src/Config/ConfigServiceProvider.php
+++ b/src/Config/ConfigServiceProvider.php
@@ -3,24 +3,33 @@
namespace Engelsystem\Config;
use Engelsystem\Container\ServiceProvider;
+use Exception;
class ConfigServiceProvider extends ServiceProvider
{
+ /** @var array */
+ protected $configFiles = ['config.default.php', 'config.php'];
+
public function register()
{
- $defaultConfigFile = config_path('config.default.php');
- $configFile = config_path('config.php');
-
$config = $this->app->make(Config::class);
$this->app->instance('config', $config);
- $config->set(require $defaultConfigFile);
+ foreach ($this->configFiles as $file) {
+ $file = config_path($file);
+
+ if (!file_exists($file)) {
+ continue;
+ }
- if (file_exists($configFile)) {
$config->set(array_replace_recursive(
$config->get(null),
- require $configFile
+ require $file
));
}
+
+ if (empty($config->get(null))) {
+ throw new Exception('Configuration not found');
+ }
}
}