protected function recursiveDomainObjectToArray(DomainObjectInterface $domainObject, $preventRecursion, $recursionMarker) { $hash = spl_object_hash($domainObject); if (true === $preventRecursion && true === in_array($hash, $this->encounteredClasses)) { return $recursionMarker; } $converted = ObjectAccess::getGettableProperties($domainObject); array_push($this->encounteredClasses, $hash); $converted = $this->recursiveArrayOfDomainObjectsToArray($converted, $preventRecursion, $recursionMarker); return $converted; }