Revert "Fixed: flt_class work with int"
Publish PHP Package / docker (push) Successful in 6s Details

This reverts commit 7c23139384.
This commit is contained in:
madpwnhammer 2024-09-26 18:50:41 +03:00
parent 7c23139384
commit d9aae4bee9
2 changed files with 12 additions and 26 deletions

View File

@ -1,6 +1,3 @@
## v1.0.8
- Fixed flt_class filter. Now it can be used with int values that contains configs id.
## v1.0.7
- Adding support for plain class names besides to arrays, e.g:
`@flt_class:ProtoItem` == `@flt_class:["ProtoItem"]`

View File

@ -85,32 +85,21 @@ function flt_class($val, $name, $struct, $args)
$conf_path = substr($conf_path, 1) . '.conf.js';
$conf_path = \taskman\config_real_path($conf_path);
$cce = \taskman\config_fetch_by_path($conf_path);
check_config_class($cce, $args);
}
if(is_numeric($val))
{
if($val == 0)
return $val;
static $configs_cache;
if(!isset($configs_cache))
$configs_cache = \taskman\config_fetch_all();
$cce = \taskman\config_find_by_id($configs_cache, $val);
check_config_class($cce, $args);
$conf_class = $cce->class;
$target_class = $args;
if(is_array($target_class))
$target_class = $target_class[0];
if(!class_exists($target_class))
throw new Exception($val.". Target class \"".$target_class."\" is not valid");
if($conf_class != $target_class && !is_subclass_of($conf_class, $target_class))
throw new Exception($val.". Config class is \"".$conf_class."\". Must be \"".$target_class."\" or it's child");
}
return $val;
}
function check_config_class($cce, $target_class)
{
if(is_array($target_class))
$target_class = $target_class[0];
if(!class_exists($target_class))
throw new Exception($val.". Target class \"".$target_class."\" is not valid");
if($cce->class != $target_class && !is_subclass_of($cce->class, $target_class))
throw new Exception($val.". Config class is \"".$cce->class."\". Must be \"".$target_class."\" or it's child");
}