flt_class now supports plain strings besides arrays
Publish PHP Package / docker (push) Successful in 7s Details

This commit is contained in:
Pavel Shevaev 2024-03-29 17:42:41 +03:00
parent 592ec1e07e
commit 1350bfaf0f
1 changed files with 9 additions and 2 deletions

View File

@ -89,9 +89,16 @@ function flt_class($val, $name, $struct, $args)
$cce = \taskman\config_fetch_by_path($conf_path);
$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 != $args[0] && !is_subclass_of($conf_class, $args[0]))
throw new Exception($val.". Config class is \"".$conf_class."\". Must be \"".$args[0]."\" or it's child");
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;