public function getOutput($connections) { if (parent::getFormat() == "xml") { return new XMLConnectionOutput($connections); } else { if (parent::getFormat() == "json") { return new JSONConnectionOutput($connections); } else { throw new Exception("No outputformat specified"); } } }
public function getOutput($l) { if (parent::getFormat() == "xml") { return new XMLLiveboardOutput($l); } else { if (parent::getFormat() == "json") { return new JSONLiveboardOutput($l); } else { throw new Exception("No outputformat specified"); } } }
public function getOutput($vehicle) { if (parent::getFormat() == "xml") { return new XMLVehicleOutput($vehicle); } else { if (parent::getFormat() == "json") { return new JSONVehicleOutput($vehicle); } else { throw new Exception("No outputformat specified"); } } }
/** * Serve data to the client * * @param mixed $data * @param string $as * @param string $format * @param boolean $die * @return null */ function serveData($data, $as = null, $format = null, $die = true) { if ($format === null) { $format = $this->request->getFormat(); } // if switch ($format) { case FORMAT_JSON: header('Content-Type: application/json; charset=utf-8'); print do_json_encode($data, $as); break; case FORMAT_XML: header('Content-Type: application/xml; charset=utf-8'); print do_xml_encode($data, $as); break; default: print $data; } // switch if ($die) { die; } // if }