FluidTYPO3\Vhs\ViewHelpers\Format\Json\EncodeViewHelper::recursiveArrayOfDomainObjectsToArray PHP Method

recursiveArrayOfDomainObjectsToArray() protected method

Convert an array of possible DomainObject instances. The argument $possibleDomainObjects could also an associative array representation of another DomainObject - which means each value could potentially be another DomainObject, an ObjectStorage of DomainObjects or a simple value type. The type is checked and another recursive call is used to convert any nested objects.
protected recursiveArrayOfDomainObjectsToArray ( array $domainObjects, boolean $preventRecursion, mixed $recursionMarker ) : array
$domainObjects array
$preventRecursion boolean
$recursionMarker mixed
return array
    protected function recursiveArrayOfDomainObjectsToArray(array $domainObjects, $preventRecursion, $recursionMarker)
    {
        foreach ($domainObjects as $key => $possibleDomainObject) {
            if (true === $possibleDomainObject instanceof DomainObjectInterface) {
                $domainObjects[$key] = $this->recursiveDomainObjectToArray($possibleDomainObject, $preventRecursion, $recursionMarker);
            } elseif (true === $possibleDomainObject instanceof \Traversable) {
                $traversableAsArray = iterator_to_array($possibleDomainObject);
                $domainObjects[$key] = $this->recursiveArrayOfDomainObjectsToArray($traversableAsArray, $preventRecursion, $recursionMarker);
            }
        }
        return $domainObjects;
    }