/** * 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; }
/** * Set whether the output should be explicitly JSON. * * @param boolean $isJson * Whether to force json output. */ public static function setJson($isJson) { static::$isJson = $isJson; }