Adding base config class configurable validation

This commit is contained in:
Pavel Shevaev 2023-12-01 15:07:10 +03:00
parent db01d08320
commit 8313da0e2d
1 changed files with 4 additions and 0 deletions

View File

@ -5,6 +5,7 @@ use Exception;
$GLOBALS['CONFIG_BASE_DIRS'] = array();
$GLOBALS['CONFIG_INIT_WORKER_FUNC'] = null;
$GLOBALS['CONFIG_FILTER_FN'] = null;
$GLOBALS['CONFIG_BASE_CLASS'] = '\ConfBase';
task('config_worker', function(array $args)
{
@ -870,6 +871,9 @@ function config_load_ex($conf_dir, $file, array $arr, $id = null)
if(!class_exists($klass))
throw new Exception("No such class '$klass'");
$cnf = new $klass;
if(!is_a($cnf, $GLOBALS['CONFIG_BASE_CLASS']))
throw new Exception("Class '$klass' must inherit from '{$GLOBALS['CONFIG_BASE_CLASS']}'");
$cnf->import($arr, true);
}
catch(Exception $e)