Migrating to new taskman_config 5.0 API
Publish PHP Package / docker (push) Successful in 6s Details

This commit is contained in:
Pavel Shevaev 2025-02-24 19:27:41 +03:00
parent f8a5f57505
commit a9dd5b5757
1 changed files with 12 additions and 9 deletions

View File

@ -2,8 +2,9 @@
namespace metagen_php;
use Exception;
function flt_str2num($val, $name, $struct, $args)
function flt_str2num($val, $name, $data, $args)
{
$config_globals = $GLOBALS['CONFIG_GLOBALS'];
$config_extra = $GLOBALS['CONFIG_EXTRAS'];
if(!property_exists($config_extra, 'flt_str2num_entries'))
$config_extra->flt_str2num_entries = array();
@ -19,7 +20,7 @@ function flt_str2num($val, $name, $struct, $args)
$name = substr($val, 1) . '.conf.js';
$path = \taskman\config_real_path($name);
$path = \taskman\config_real_path($config_globals->base_dirs, $name);
if(\taskman\config_get_header($path, $proto_id, $alias))
{
@ -51,11 +52,11 @@ function validate_flt_str2num(\taskman\ConfigFetchResult $fetch_result, \taskman
if($conf_id == 0)
continue;
\taskman\config_find_by_id($fetch_result, $conf_id);
$fetch_result->getById($conf_id);
}
}
function flt_range($val, $name, $struct, $args)
function flt_range($val, $name, $data, $args)
{
if(count($args) != 2)
throw new Exception("Wrong usage of \"flt_range\". Use \"@flt_range:[0,1]\" where 0 - min, 1 - max");
@ -72,7 +73,7 @@ function flt_range($val, $name, $struct, $args)
return $val;
}
function flt_time($val, $name, $struct, $args)
function flt_time($val, $name, $data, $args)
{
$str = "";
if(is_string($val))
@ -95,7 +96,7 @@ function flt_time($val, $name, $struct, $args)
return 0;
}
function flt_class($val, $name, $struct, $args)
function flt_class($val, $name, $data, $args)
{
global $GAME_ROOT;
@ -121,6 +122,8 @@ function validate_flt_class(\taskman\ConfigFetchResult $fetch_result, \taskman\C
if(!property_exists($config_extra, 'flt_class_entries'))
return;
$config_globals = $GLOBALS['CONFIG_GLOBALS'];
foreach($config_extra->flt_class_entries as $conf_ref => $target_class)
{
@ -136,16 +139,16 @@ function validate_flt_class(\taskman\ConfigFetchResult $fetch_result, \taskman\C
if(strpos($conf_path, '@') === 0)
$conf_path = substr($conf_path, 1) . '.conf.js';
$conf_path = \taskman\normalize_path(\taskman\config_real_path($conf_path), true);
$conf_path = \taskman\normalize_path(\taskman\config_real_path($config_globals, $conf_path), true);
$conf_cache = \taskman\config_find_by_path($fetch_result, $conf_path);
$conf_cache = $fetch_result->getByPath($conf_path);
}
else if(is_int($conf_ref))
{
if($conf_ref == 0)
continue;
$conf_cache = \taskman\config_find_by_id($fetch_result, $conf_ref);
$conf_cache = $fetch_result->getById($conf_ref);
}
else
throw new Exception("Invalid config ref: '$conf_ref'");