From 91ed9344f3b281413b740c5405b15eea01d84987 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Thu, 25 May 2023 18:44:59 +0300 Subject: [PATCH] Base dirs now can be configured via config_set_base_dirs(..) call, further removing global props dependencies --- config.inc.php | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/config.inc.php b/config.inc.php index a393b6f..86a8f3d 100644 --- a/config.inc.php +++ b/config.inc.php @@ -3,6 +3,7 @@ namespace taskman; use Exception; $GLOBALS['CONFIG_GLOBAL_DEPS'] = array(); +$GLOBALS['CONFIG_BASE_DIRS'] = array(); $GLOBALS['CONFIG_INIT_WORKER_FUNC'] = null; task('config_worker', function(array $args) @@ -29,24 +30,16 @@ task('config_worker', function(array $args) } }); +function config_set_base_dirs(array $dirs) +{ + global $CONFIG_BASE_DIRS; + $CONFIG_BASE_DIRS = array_map(function($d) { return normalize_path($d); }, $dirs); +} + function config_base_dirs() { - static $dirs = null; - - if($dirs === null) - { - if(is("CONFIGS_BASE_DIR")) - { - $dirs = get("CONFIGS_BASE_DIR"); - if(is_string($dirs)) - $dirs = array($dirs); - } - else - $dirs = array(get("UNITY_ASSETS_DIR") . "/Configs"); - - $dirs = array_map(function($d) { return normalize_path($d); }, $dirs); - } - return $dirs; + global $CONFIG_BASE_DIRS; + return $CONFIG_BASE_DIRS; } function config_map_base_dir($file, $normalized = false, $strict = true, $dirs = null) @@ -103,17 +96,6 @@ function config_get_global_deps() return $CONFIG_GLOBAL_DEPS; } -function config_get_build_ext_dir() -{ - global $GAME_ROOT; - return "$GAME_ROOT/build/ext_config/"; -} - -function config_get_bundle_ext_path() -{ - return config_get_build_ext_dir() . "/configs/" . get("CONFIGS_BUNDLE_NAME"); -} - function config_scan_files() { return scan_files_rec(config_base_dirs(), array('conf.js'));