summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-08-10 15:02:07 +0200
committermsquare <msquare@notrademark.de>2018-08-12 17:38:36 +0200
commitd243090fea52b68a5ad5d55a5927ca95b5bf8bb1 (patch)
tree08c3810a9e32b0368a2518b0823d4fccaec98ce4 /src
parentf46e921b710b02d5a1f17f0dd076a5bf085ae735 (diff)
config: allow renaming of config.default.php to config.php
Closes #444 (Problems after installation)
Diffstat (limited to 'src')
-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');
+ }
}
}