From 1350bfaf0f65043ea6ac4be5b290443b3b7ce311 Mon Sep 17 00:00:00 2001 From: Pavel Shevaev Date: Fri, 29 Mar 2024 17:42:41 +0300 Subject: [PATCH] flt_class now supports plain strings besides arrays --- filters.inc.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/filters.inc.php b/filters.inc.php index 64c59cd..73c6d7b 100644 --- a/filters.inc.php +++ b/filters.inc.php @@ -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;