$tpList = $tp->getPorts(); // Convert the base template object to an associative array for easier manipulation $postData["template"] = json_decode(json_encode($temp), true); $postData["templateports"] = array(); foreach ($tpList as $tport) { array_push($postData["templateports"], json_decode(json_encode($tport), true)); } $tpp = new TemplatePowerPorts(); $tpp->TemplateID = $temp->TemplateID; $tppList = $tpp->getPorts(); $postData["templatepowerports"] = array(); foreach ($tppList as $pport) { array_push($postData["templatepowerports"], json_decode(json_encode($pport), true)); } if ($temp->DeviceType == "Chassis") { $sList = Slot::getSlots($temp->TemplateID); $postData["slots"] = array(); foreach ($sList as $s) { array_push($postData["slots"], json_decode(json_encode($s), true)); } } if ($temp->DeviceType == "CDU") { $ct->TemplateID = $temp->TemplateID; $ct->GetTemplate(); $postData["cdutemplate"] = json_decode(json_encode($ct), true); } if ($temp->DeviceType == "Sensor") { $sen->TemplateID = $temp->TemplateID; $sen->GetTemplate(); $postData["sensortemplate"] = json_decode(json_encode($sen), true); }