Ejemplo n.º 1
0
function parse_element($type, $confObj)
{
    $elementlist = array();
    if ("step" == $type) {
        $objlist = $confObj["steps"];
    } elseif ("collect" == $type) {
        $objlist = $confObj["collects"];
    }
    foreach ($objlist as $obj) {
        if ("step" == $type) {
            $element = new Step();
        } elseif ("collect" == $type) {
            $element = new Collect();
        }
        $element->setName($obj[$type . ".name"]);
        $element->setCmd($obj[$type . ".cmd"]);
        $element->setDesc($obj[$type . ".desc"]);
        if (array_key_exists($type . ".hostname", $obj)) {
            $element->setHostName($obj[$type . ".hostname"]);
        }
        if (array_key_exists($type . ".cmd.sep", $obj)) {
            $element->setCmdSep($obj[$type . ".cmd.sep"]);
        }
        if (array_key_exists($type . ".ignore_fail", $obj)) {
            $element->setIgnoreFail($obj[$type . ".ignore_fail"]);
        }
        array_push($elementlist, $element);
    }
    return $elementlist;
}