Ejemplo n.º 1
0
 /**
  * Check if request content-type is in JSON format
  *
  * @return bool
  */
 protected static function isRequestJson()
 {
     if (null === static::$isJson) {
         static::$isJson = false;
         $ContentType = static::getRequest()->getHeaders('Content-Type');
         if ($ContentType) {
             $value = $ContentType->getFieldValue();
             static::$isJson = false !== stripos($value, 'application/json');
         }
     }
     return static::$isJson;
 }
Ejemplo n.º 2
0
 /**
  * Set whether the output should be explicitly JSON.
  *
  * @param boolean $isJson
  *   Whether to force json output.
  */
 public static function setJson($isJson) {
     static::$isJson = $isJson;
 }