PHP Class Dingo\Api\Http\Response

Inheritance: extends Illuminate\Http\Response
Afficher le fichier Open project: dingo/api Class Usage Examples

Méthodes publiques

Свойство Type Description
$exception Exception The exception that triggered the error response.

Protected Properties

Свойство Type Description
$binding Dingo\Api\Transformer\Binding Transformer binding instance.
$events Illuminate\Events\Dispatcher Event dispatcher instance.
$formatters array Array of registered formatters.
$transformer Dingo\Api\Transformer\TransformerFactory Transformer factory instance.

Méthodes publiques

Méthode Description
__construct ( mixed $content, integer $status = 200, array $headers = [], Dingo\Api\Transformer\Binding $binding = null ) : void Create a new response instance.
addFormatter ( string $key, Dingo\Api\Http\Response\Format\Format $formatter ) : void Add a response formatter.
addMeta ( string $key, mixed $value ) : Response Add a meta key and value pair.
cookie ( Cookie | mixed $cookie ) : Response Add a cookie to the response.
getFormatter ( string $format ) : Dingo\Api\Http\Response\Format\Format Get the formatter based on the requested format type.
getMeta ( ) : array Get the meta data for the response.
getTransformer ( ) : Dingo\Api\Transformer\Factory Get the transformer instance.
hasFormatter ( string $format ) : boolean Determine if a response formatter has been registered.
makeFromExisting ( Illuminate\Http\Response $old ) : Response Make an API response from an existing Illuminate response.
makeFromJson ( Illuminate\Http\JsonResponse $json ) : Response Make an API response from an existing JSON response.
meta ( string $key, mixed $value ) : Response Add a meta key and value pair.
morph ( string $format = 'json' ) : Response Morph the API response to the appropriate format.
setContent ( $content )
setEventDispatcher ( Illuminate\Events\Dispatcher $events ) : void Set the event dispatcher instance.
setFormatters ( array $formatters ) : void Set the response formatters.
setMeta ( array $meta ) : Response Set the meta data for the response.
setTransformer ( Dingo\Api\Transformer\Factory $transformer ) : void Set the transformer factory instance.
statusCode ( integer $statusCode ) : Response Set the response status code.
withHeader ( string $key, string $value, boolean $replace = true ) : Response Add a header to the response.

Méthodes protégées

Méthode Description
fireMorphedEvent ( ) : void Fire the morphed event.
fireMorphingEvent ( ) : void Fire the morphing event.

Method Details

__construct() public méthode

Create a new response instance.
public __construct ( mixed $content, integer $status = 200, array $headers = [], Dingo\Api\Transformer\Binding $binding = null ) : void
$content mixed
$status integer
$headers array
$binding Dingo\Api\Transformer\Binding
Résultat void

addFormatter() public static méthode

Add a response formatter.
public static addFormatter ( string $key, Dingo\Api\Http\Response\Format\Format $formatter ) : void
$key string
$formatter Dingo\Api\Http\Response\Format\Format
Résultat void

addMeta() public méthode

Add a meta key and value pair.
public addMeta ( string $key, mixed $value ) : Response
$key string
$value mixed
Résultat Response

fireMorphedEvent() protected méthode

Fire the morphed event.
protected fireMorphedEvent ( ) : void
Résultat void

fireMorphingEvent() protected méthode

Fire the morphing event.
protected fireMorphingEvent ( ) : void
Résultat void

getFormatter() public static méthode

Get the formatter based on the requested format type.
public static getFormatter ( string $format ) : Dingo\Api\Http\Response\Format\Format
$format string
Résultat Dingo\Api\Http\Response\Format\Format

getMeta() public méthode

Get the meta data for the response.
public getMeta ( ) : array
Résultat array

getTransformer() public static méthode

Get the transformer instance.
public static getTransformer ( ) : Dingo\Api\Transformer\Factory
Résultat Dingo\Api\Transformer\Factory

hasFormatter() public static méthode

Determine if a response formatter has been registered.
public static hasFormatter ( string $format ) : boolean
$format string
Résultat boolean

makeFromExisting() public static méthode

Make an API response from an existing Illuminate response.
public static makeFromExisting ( Illuminate\Http\Response $old ) : Response
$old Illuminate\Http\Response
Résultat Response

makeFromJson() public static méthode

Make an API response from an existing JSON response.
public static makeFromJson ( Illuminate\Http\JsonResponse $json ) : Response
$json Illuminate\Http\JsonResponse
Résultat Response

meta() public méthode

Add a meta key and value pair.
public meta ( string $key, mixed $value ) : Response
$key string
$value mixed
Résultat Response

morph() public méthode

Morph the API response to the appropriate format.
public morph ( string $format = 'json' ) : Response
$format string
Résultat Response

setContent() public méthode

public setContent ( $content )

setEventDispatcher() public static méthode

Set the event dispatcher instance.
public static setEventDispatcher ( Illuminate\Events\Dispatcher $events ) : void
$events Illuminate\Events\Dispatcher
Résultat void

setFormatters() public static méthode

Set the response formatters.
public static setFormatters ( array $formatters ) : void
$formatters array
Résultat void

setMeta() public méthode

Set the meta data for the response.
public setMeta ( array $meta ) : Response
$meta array
Résultat Response

setTransformer() public static méthode

Set the transformer factory instance.
public static setTransformer ( Dingo\Api\Transformer\Factory $transformer ) : void
$transformer Dingo\Api\Transformer\Factory
Résultat void

statusCode() public méthode

Set the response status code.
public statusCode ( integer $statusCode ) : Response
$statusCode integer
Résultat Response

withHeader() public méthode

Add a header to the response.
public withHeader ( string $key, string $value, boolean $replace = true ) : Response
$key string
$value string
$replace boolean
Résultat Response

Property Details

$binding protected_oe property

Transformer binding instance.
protected Binding,Dingo\Api\Transformer $binding
Résultat Dingo\Api\Transformer\Binding

$events protected_oe static_oe property

Event dispatcher instance.
protected static Dispatcher,Illuminate\Events $events
Résultat Illuminate\Events\Dispatcher

$exception public_oe property

The exception that triggered the error response.
public Exception $exception
Résultat Exception

$formatters protected_oe static_oe property

Array of registered formatters.
protected static array $formatters
Résultat array

$transformer protected_oe static_oe property

Transformer factory instance.
protected static TransformerFactory,Dingo\Api\Transformer $transformer
Résultat Dingo\Api\Transformer\TransformerFactory