Overview
  • Namespace
  • Class
  • Tree

Namespaces

  • Modulework
    • Modules
      • Http
        • Exceptions
        • Utilities
  • PHP

Classes

  • Cookie
  • JsonResponse
  • RedirectResponse
  • Request
  • Response

Class JsonResponse

JSON-Response A HTTP Response in the JSON format (application/json)

Modulework\Modules\Http\Response
Extended by Modulework\Modules\Http\JsonResponse
Namespace: Modulework\Modules\Http
Located at Modulework/Modules/Http/JsonResponse.php

Methods summary

public static Modulework\Modules\Http\JsonResponse
# make( mixed $json = null, integer $code = 200, array $headers = array(), Modulework\Modules\Http\Utilities\HeaderWrapperInterface $headerWrapper = null )

Factory for the Response object

Factory for the Response object

Parameters

$json
mixed
$content The data which gets encoded to json
$code
integer
$code The HTTP status code
$headers
array
$headers The HTTP headers
$headerWrapper
Modulework\Modules\Http\Utilities\HeaderWrapperInterface
| null $headerWrapper The wrapper for PHP' s native header releated functions

Returns

Modulework\Modules\Http\JsonResponse
The new JsonResponse object

Throws

InvalidArgumentException
(from Constructor)

Overrides

Modulework\Modules\Http\Response::make
public Modulework\Modules\Http\JsonResponse
# __construct( mixed $json = null, integer $code = 200, array $headers = array(), Modulework\Modules\Http\Utilities\HeaderWrapperInterface $headerWrapper = null )

Constructor.

Constructor.

Parameters

$json
mixed
$content The data which gets encoded to json
$code
integer
$code The HTTP status code
$headers
array
$headers The HTTP headers
$headerWrapper
Modulework\Modules\Http\Utilities\HeaderWrapperInterface
| null $headerWrapper The wrapper for PHP' s native header releated functions

Returns

Modulework\Modules\Http\JsonResponse
The new JsonResponse object

Throws

InvalidArgumentException
(from setContent)

Overrides

Modulework\Modules\Http\Response::__construct
public Modulework\Modules\Http\JsonResponse
# setJson( mixed $json = array(), boolean $json_string = false )

Set the json data for the response

Set the json data for the response

Parameters

$json
mixed
$json The data (a JSON string is possible as well) which gets encoded
$json_string
boolean
$json_string Whether the input doesn' t need to get encoded

Returns

Modulework\Modules\Http\JsonResponse
THIS
public mixed|string
# getJson( boolean $raw = false )

Returns the json data

Returns the json data

Parameters

$raw
boolean
$raw Whether it shoud return the raw or encoded data

Returns

mixed|string
The json data
public Modulework\Modules\Http\JsonResponse
# setCallback( string $callback = null )

Set the json callback for the response

Set the json callback for the response

Parameters

$callback
string
$callback The callback

Returns

Modulework\Modules\Http\JsonResponse
THIS

Throws

InvalidArgumentException
public string
# getCallback( )

Returns the callback

Returns the callback

Returns

string
The callback
protected Modulework\Modules\Http\JsonResponse
# refresh( )

Updates all parameters (changing headers and setting content)

Updates all parameters (changing headers and setting content)

Returns

Modulework\Modules\Http\JsonResponse
THIS
protected static boolean
# isValidIdentifier( string $callback )

Checks if the string is a valid javascript identifier Taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier Formatting modified + minor changes

Checks if the string is a valid javascript identifier Taken from http://www.geekality.net/2011/08/03/valid-javascript-identifier Formatting modified + minor changes

Parameters

$callback
string
$callback The string to check

Returns

boolean
Whether the string is valid

Methods inherited from Modulework\Modules\Http\Response

__toString(), addCookie(), addHeader(), appendContent(), fromException(), getCharset(), getContent(), getDate(), getExpires(), getProtocolVersion(), getStatusCode(), isClientError(), isEmpty(), isForbidden(), isInformational(), isInvalid(), isNotFound(), isOk(), isRedirect(), isServerError(), isSuccess(), prepare(), send(), sendContent(), sendCookies(), sendHeaders(), setCharset(), setContent(), setDate(), setExpires(), setHeaderWrapper(), setProtocolVersion(), setStatusCode(), validateContent()

Magic methods summary

Constants summary

string CONTENTTYPE_JS 'application/javascript'
#
string CONTENTTYPE_JSON 'application/json'
#

Properties summary

protected mixed $callback
#
protected mixed $json
#
protected mixed $rawdata
#

Properties inherited from Modulework\Modules\Http\Response

$charset, $content, $cookies, $headerWrapper, $headers, $protocolVersion, $statusCode, $statusCodeRegistry, $statusText

API documentation generated by ApiGen 2.8.0