[TASK] ObjectUtility: Add function to clear object data

This commit is contained in:
Philipp Dieter 2022-11-17 14:31:34 +01:00
parent ec7bb84f5e
commit e126e674c7

View File

@ -136,4 +136,31 @@ class ObjectUtility
}
}
}
/**
* Clears all object fields
*
* @return void
*/
public static function clearData(
&$object
) {
foreach ($object->_getProperties() as $property => $value) {
if ($property == 'uid' || $property == 'pid') {
continue;
}
switch (getType($value)) {
case 'string':
$object->_setProperty($property, '');
break;
case 'boolean':
$object->_setProperty($property, false);
break;
case 'integer':
$object->_setProperty($property, 0);
break;
}
}
}
}