Stud.IP  4.2 Revision
Response Class Reference
Collaboration diagram for Response:
Collaboration graph

Public Member Functions

 __construct (array $variables=[])
 
 addHeader ($name, $content, $append=false)
 
 addHeaders (array $headers, $append=false)
 
 getHeaders ()
 
 setStatus ($status)
 
 getStatus ()
 
 setContent ($content)
 
 getContent ()
 
 connectWithRouteMap (RouteMap $map)
 
 connectWithTrailsResponse (Trails_Response $response)
 

Protected Attributes

 $headers = []
 
 $status = 200
 
 $content = false
 
 $variables
 

Detailed Description

Widget API/execution response.

Todo:
This is rather ugly and annoying besides the RESTAPI and Trails_Response which basically do the same thing (working with http status, headers and responses). Ideally all of these should use the same PSR-7 compatible HTTP Response object.
Author
Jan-Hendrik Willms tleil.nosp@m.ax+s.nosp@m.tudip.nosp@m.@gma.nosp@m.il.co.nosp@m.m GPL2 or any later version

Constructor & Destructor Documentation

◆ __construct()

__construct ( array  $variables = [])

Constructs this response with a predefined set of variables that are used to replace placeholders in headers.

Parameters
array$variablesSet of variables

Member Function Documentation

◆ addHeader()

addHeader (   $name,
  $content,
  $append = false 
)

Adds a new header to the response. The header name and content may contain placeholders in the form ":var" which are replaced with the predefined set of variables in the constructor.

Parameters
string$nameName of the header
string$contetnContent of the header
bool$appendShould the header be appended to a previously added header with the same name or should it replace that header (defaults to false, replace)
Here is the caller graph for this function:

◆ addHeaders()

addHeaders ( array  $headers,
  $append = false 
)

Adds an associative array of headers (the key is name of the header, the value is the content).

Parameters
array$headersArray of headers
bool$appendAppend or replace existing headers (
See also
addheader)
Here is the caller graph for this function:

◆ connectWithRouteMap()

connectWithRouteMap ( RouteMap  $map)

Connects this response with a route map of the Stud.IP core api. This means, that this response is mapped to the route map's response with all it's headers, the status and the content.

Parameters
RouteMap$mapThe connected route map
Here is the call graph for this function:

◆ connectWithTrailsResponse()

connectWithTrailsResponse ( Trails_Response  $response)

Connects this response with the response of a trails controller. This means, that this response is mapped to the trails response with all it's headers, the status and the content.

Parameters
Trails_Response$responseThe connected trails response

◆ getContent()

getContent ( )

Returns the content of the response. If the content was set as a flexi template, this will return the rendered template.

Returns
string Content of the response

◆ getHeaders()

getHeaders ( )

Returns the previously set headers.

Returns
array of header (key = name, value = content)

◆ getStatus()

getStatus ( )

Returns the status code of the response. If the status is not a redirect (300), an error (400) or an exception (500) and no content has been set, the status will always return 204 (= No Content).

Returns
int http status of the response

◆ setContent()

setContent (   $content)

Sets the content of the response.

Parameters
mixed$contentContent of the response (might be a string or a flexi template)

◆ setStatus()

setStatus (   $status)

Sets the http status of the response.

Parameters
int$statusStatus code of the response

Field Documentation

◆ $content

$content = false
protected

◆ $headers

$headers = []
protected

◆ $status

$status = 200
protected

◆ $variables

$variables
protected

The documentation for this class was generated from the following file: