PS::_addchild PHP Method

_addchild() private method

recursive function to allow appending child processes to a parent process
private _addchild ( Array $child, SimpleXMLExtended $xml, &$positions ) : SimpleXMLExtended
$child Array part of the array which should be appended to the XML
$xml SimpleXMLExtended XML-Object to which the array content is appended
return SimpleXMLExtended Object with the appended array content
    private function _addchild($child, SimpleXMLExtended $xml, &$positions)
    {
        foreach ($child as $key => $value) {
            $xmlnode = $xml->addChild("Process");
            if (isset($value[0])) {
                array_push($positions, $value[0]);
                $xmlnode->addAttribute('PID', $value[0]);
                $parentid = array_search($value[1], $positions);
                $xmlnode->addAttribute('ParentID', $parentid);
                $xmlnode->addAttribute('PPID', $value[1]);
                $xmlnode->addAttribute('MemoryUsage', $value[2]);
                $xmlnode->addAttribute('Name', $value[3]);
                if (PSI_OS !== 'WINNT') {
                    if ($parentid === 1) {
                        $xmlnode->addAttribute('Expanded', 0);
                    }
                    if (defined('PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED') && PSI_PLUGIN_PS_SHOW_KTHREADD_EXPANDED === false && $value[3] === "[kthreadd]") {
                        $xmlnode->addAttribute('Expanded', 0);
                    }
                }
            }
            if (isset($value['childs'])) {
                $this->_addChild($value['childs'], $xml, $positions);
            }
        }
        return $xml;
    }