src/ORM/Hierarchy/MarkedSet.php
protected function getSubtreeAsArray($data, $serialiseEval)
    {
        $output = $data;

        // Serialise node
        $serialised = $serialiseEval($data['node']);

        // Force serialisation of DBField instances
        if (is_array($serialised)) {
            foreach ($serialised as $key => $value) {
                if ($value instanceof DBField) {
                    $serialised[$key] = $value->getSchemaValue();
                }
            }

            // Merge with top level array
            unset($output['node']);
            $output = array_merge($output, $serialised);
        } else {
            if ($serialised instanceof DBField) {
                $serialised = $serialised->getSchemaValue();
            }

            // Replace node with serialised value
            $output['node'] = $serialised;
        }

        // Replace children with serialised elements
        $output['children'] = [];
        foreach ($data['children'] as $child) {
            $output['children'][] = $this->getSubtreeAsArray($child, $serialiseEval);
        }
        return $output;
    }
protected function getSubtreeAsArray($data, $serialiseEval)
    {
        $output = $data;

        // Serialise node
        $serialised = $serialiseEval($data['node']);

        // Force serialisation of DBField instances
        if (is_array($serialised)) {
            foreach ($serialised as $key => $value) {
                if ($value instanceof DBField) {
                    $serialised[$key] = $value->getSchemaValue();
                }
            }

            // Merge with top level array
            unset($output['node']);
            $output = array_merge($output, $serialised);
        } else {
            if ($serialised instanceof DBField) {
                $serialised = $serialised->getSchemaValue();
            }

            // Replace node with serialised value
            $output['node'] = $serialised;
        }

        // Replace children with serialised elements
        $output['children'] = [];
        foreach ($data['children'] as $child) {
            $output['children'][] = $this->getSubtreeAsArray($child, $serialiseEval);
        }
        return $output;
    }
protected function getSubtreeAsArray ( $ data , $ serialiseEval ) { $ output = $ data ; // Serialise node $ serialised = $ serialiseEval ( $ data [ 'node' ] ) ; // Force serialisation of DBField instances if ( is_array ( $ serialised ) ) { foreach ( $ serialised as $ key => $ value ) { if ( $ value instanceof DBField ) { $ serialised [ $ key ] = $ value -> getSchemaValue ( ) ; } } // Merge with top level array unset ( $ output [ 'node' ] ) ; $ output = array_merge ( $ output , $ serialised ) ; } else { if ( $ serialised instanceof DBField ) { $ serialised = $ serialised -> getSchemaValue ( ) ; } // Replace node with serialised value $ output [ 'node' ] = $ serialised ; } // Replace children with serialised elements $ output [ 'children' ] = [ ] ; foreach ( $ data [ 'children' ] as $ child ) { $ output [ 'children' ] [ ] = $ this -> getSubtreeAsArray ( $ child , $ serialiseEval ) ; } return $ output ; }
Return sub-tree as json array

@param array $data
@param callable $serialiseEval A callback that takes a DataObject as a single parameter,
and should return an array containing a simple array representation. This result will
replace the 'node' property at each point in the tree.
@return mixed|string
Return sub - tree as json array