Added configuration validator class (#1215)

* Added configuration validator class

* Review

Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
Marc Ole Bulling
2020-12-23 17:37:05 +01:00
committed by GitHub
parent 2f8207ab5f
commit 80acc7deea
2 changed files with 95 additions and 0 deletions

11
app.php
View File

@@ -12,6 +12,7 @@ require_once __DIR__ . '/vendor/autoload.php';
// Load config files
require_once GROCY_DATAPATH . '/config.php';
require_once __DIR__ . '/config-dist.php'; // For not in own config defined values we use the default ones
require_once __DIR__ . '/helpers/ConfigurationValidator.php';
// Definitions for dev/demo/prerelease mode
if ((GROCY_MODE === 'dev' || GROCY_MODE === 'demo' || GROCY_MODE === 'prerelease') && !defined('GROCY_USER_ID'))
@@ -31,6 +32,16 @@ if (GROCY_DISABLE_AUTH === true)
define('GROCY_SHOW_AUTH_VIEWS', false);
}
// Check if any invalid entries in config.php have been made
try
{
(new ConfigurationValidator())->validateConfig();
}
catch (EInvalidConfig $ex)
{
exit('Invalid setting in config.php: ' . $ex->getMessage());
}
// Setup base application
AppFactory::setContainer(new DI\Container());
$app = AppFactory::create();