Response Interface Reference

Detailed Description

Response holds the response values that are used as output from Controller instances.

It is typically instantiated by the ActionMapper instance and filled during Controller execution.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 20 of file Response.php.

+ Inheritance diagram for Response:

Public Member Functions

 setRequest (Request $request)
 
 getRequest ()
 
 setCacheId ($cacheId)
 
 getCacheId ()
 
 setCacheLifetime ($seconds)
 
 getCacheLifetime ()
 
 isCached ()
 
 getCacheDate ()
 
 setStatus ($status)
 
 getStatus ()
 
 setFile ($filename, $isDownload, $content='', $type='')
 
 getFile ()
 
 setDocument (ResponseDocument $document)
 
 getDocument ()
 
- Public Member Functions inherited from ControllerMessage
 setSender ($sender)
 
 getSender ()
 
 setContext ($context)
 
 getContext ()
 
 setAction ($action)
 
 getAction ()
 
 setFormat ($format)
 
 getFormat ()
 
 setHeader ($name, $value)
 
 setHeaders (array $headers)
 
 getHeader ($name, $default=null)
 
 getHeaders ()
 
 clearHeader ($name)
 
 clearHeaders ()
 
 hasHeader ($name)
 
 setValue ($name, $value)
 
 setValues (array $values)
 
 getValue ($name, $default=null, $validateDesc=null, $suppressException=false)
 
 getBooleanValue ($name, $default=false)
 
 getValues ()
 
 clearValue ($name)
 
 clearValues ()
 
 hasValue ($name)
 
 setProperty ($name, $value)
 
 getProperty ($name)
 
 addError (ApplicationError $error)
 
 setErrors (array $errors)
 
 getErrors ()
 
 clearErrors ()
 
 hasErrors ()
 

Member Function Documentation

◆ setRequest()

setRequest ( Request  $request)

Set the Request instance belonging to the response and vice versa.

Parameters
$requestRequest

Implemented in DefaultResponse.

◆ getRequest()

getRequest ( )

Get the Request instance belonging to the response.

Returns
Request

Implemented in DefaultResponse.

◆ setCacheId()

setCacheId (   $cacheId)

Set a string value that uniquely identifies the request data resulting in the current response.

If this value is not null, it will be used to compare two requests and return cached responses based on the result. Set a value of null to prevent caching.

Parameters
$cacheId

Implemented in DefaultResponse.

◆ getCacheId()

getCacheId ( )

Get the cache id.

See also
Response::setCacheId()
Returns
The id

Implemented in DefaultResponse.

◆ setCacheLifetime()

setCacheLifetime (   $seconds)

Set the lifetime of a cached response.

After this time previously cached response is dicarded. Set a value of -1 for an infinite lifetime.

Parameters
$seconds

Implemented in DefaultResponse.

◆ getCacheLifetime()

getCacheLifetime ( )

Get the lifetime of a cached response.

A value of null means an infinite lifetime.

Returns
Integer

Implemented in DefaultResponse.

◆ isCached()

isCached ( )

Check if the response is cached.

Controllers may use the result to determine if the controller logic must be executed or not.

Returns
Boolean

Implemented in DefaultResponse.

◆ getCacheDate()

getCacheDate ( )

Get the caching date, if the response is cached.

Returns
DateTime or null, if not cached

Implemented in DefaultResponse.

◆ setStatus()

setStatus (   $status)

Set the response HTTP status code.

Parameters
$statusThe HTTP status code

Implemented in DefaultResponse.

◆ getStatus()

getStatus ( )

Get the response HTTP status code.

Returns
Integer

Implemented in DefaultResponse.

◆ setFile()

setFile (   $filename,
  $isDownload,
  $content = '',
  $type = '' 
)

Set a file as response.

Deprecated:
Use setDocument() instead
Parameters
$filenameThe name of the file, must be a real file, if no content is provided
$isDownloadBoolean, indicating whether the file should be return as download or not
$contentFile content, if in-memory only (optional)
$typeFile mime type, if in-memory only (optional)

Implemented in DefaultResponse.

◆ getFile()

getFile ( )

Get the file download.

Deprecated:
Use getDocument() instead
Returns
Array with keys 'isDownload', 'filename', 'content' and 'type' or null

Implemented in DefaultResponse.

◆ setDocument()

setDocument ( ResponseDocument  $document)

Set a response document.

Parameters
$documentThe ResponseDocument instance

Implemented in DefaultResponse.

◆ getDocument()

getDocument ( )

Get the response document.

Returns
ResponseDocument

Implemented in DefaultResponse.