getFormat() public static method

Gets the format associated with the mime type.
public static getFormat ( string $mimeType ) : string | null
$mimeType string The associated mime type
return string | null The format (null if not found)
Esempio n. 1
0
 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");
         }
     }
 }
Esempio n. 2
0
 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");
         }
     }
 }
Esempio n. 3
0
 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
 }