Commit 5c09fbdf authored by Ad Schellevis's avatar Ad Schellevis

(mvc) support inheritance of OPNsense\Base\FieldTypes\BaseField children.

parent 3c8e1465
......@@ -122,7 +122,16 @@ abstract class BaseModel
if (class_exists($classname)) {
// construct field type object
$field_rfcls = new \ReflectionClass($classname);
if ($field_rfcls->getParentClass()->name != 'OPNsense\Base\FieldTypes\BaseField') {
$check_derived = $field_rfcls->getParentClass();
$is_derived_from_basefield = false;
while ($check_derived != false) {
if ($check_derived->name == 'OPNsense\Base\FieldTypes\BaseField') {
$is_derived_from_basefield = true;
break;
}
$check_derived = $check_derived->getParentClass();
}
if (!$is_derived_from_basefield) {
// class found, but of wrong type. raise an exception.
throw new ModelException("class ".$field_rfcls->name." of wrong type in model definition");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment