src/CMDBLocationTree.php
public function readRecursively($objectID, $status = null) {
        $children = $this->read($objectID, $status);

        $tree = [];

        foreach ($children as $child) {
            if (!array_key_exists('id', $child)) {
                throw new RuntimeException('Broken result');
            }

            $node = $child;

            $childChildren = $this->read((int) $child['id'], $status);

            if (count($childChildren) > 0) {
                $node['children'] = $childChildren;
            }

            $tree[] = $node;
        }

        return $tree;
    }
public function readRecursively($objectID, $status = null) {
        $children = $this->read($objectID, $status);

        $tree = [];

        foreach ($children as $child) {
            if (!array_key_exists('id', $child)) {
                throw new RuntimeException('Broken result');
            }

            $node = $child;

            $childChildren = $this->read((int) $child['id'], $status);

            if (count($childChildren) > 0) {
                $node['children'] = $childChildren;
            }

            $tree[] = $node;
        }

        return $tree;
    }
public function readRecursively ( $ objectID , $ status = null ) { $ children = $ this -> read ( $ objectID , $ status ) ; $ tree = [ ] ; foreach ( $ children as $ child ) { if ( ! array_key_exists ( 'id' , $ child ) ) { throw new RuntimeException ( 'Broken result' ) ; } $ node = $ child ; $ childChildren = $ this -> read ( ( int ) $ child [ 'id' ] , $ status ) ; if ( count ( $ childChildren ) > 0 ) { $ node [ 'children' ] = $ childChildren ; } $ tree [ ] = $ node ; } return $ tree ; }
Reads recursively objects located under an object

@param int $objectID Object identifier
@param int $status Filter relations by status: 2 = normal, 3 = archived, 4 = deleted

@return array

@throws Exception on error
Reads recursively objects located under an object