<?phpnamespace App\Model\DataObject;class Abteilung extends \Pimcore\Model\DataObject\Abteilung{ // check if department has persons public function hasPersons() { $object = $this; $def = $object->getClass()->getFieldDefinition("persons"); $refKey = $def->getOwnerFieldName(); $refId = $def->getOwnerClassId(); $persons = $object->getRelationData($refKey, false, $refId); if (count($persons) > 0) { return true; } else { return false; } }}