Documentation

Response extends Response
in package

A cloudrexx response to a request

Tags
copyright

CLOUDREXX CMS - CLOUDREXX AG

author

Michael Ritter michael.ritter@cloudrexx.com

subpackage

core_routing

link

cloudrexx homepage

since
5.0.0

Table of Contents

Properties

$abstractContent  : mixed
$code  : int
$contentSecurityPolicy  : array<string|int, mixed>
$contentSecurityPolicyReportOnly  : array<string|int, mixed>
$contentType  : string
$expirationDate  : DateTime
$headers  : array<string|int, mixed>
$isParsed  : bool
$message  : string
$page  : Page
$parsedContent  : string
$parser  : object|callable
$request  : Request
$theme  : mixed

Methods

__construct()  : mixed
Creates a new Response
getAbstractContent()  : mixed
Returns the abstract response data
getCode()  : int
Returns the response code
getContentDisposition()  : string
Get the Content-Disposition of the response.
getContentSecurityPolicy()  : array<string|int, mixed>
Get the directives of the set Content-Security-Policy of the response.
getContentType()  : string
Returns the content type
getExpirationDate()  : DateTime
Returns the expiration date for this Response
getHeader()  : string
Returns a header's value
getHeaders()  : array<string|int, mixed>
Returns a list of headers Please note that this does not include 'Content-Type' and 'Expires' headers
getMessage()  : string
Returns the message Message may be used for user interaction or debugging and is "part" of abstract content
getPage()  : Page
Returns the current page for this response
getParsedContent()  : string
Returns the parsed response data
getParser()  : object|callable
Returns the parser
getRequest()  : Request
Returns the Request object for this Response
getTheme()  : Theme
Returns the current theme
parse()  : mixed
Parses this response
send()  : string
Exposes any set HTTP header to the client and returns this response to the client or returns it as string if $finishRequest is set to false.
setAbstractContent()  : mixed
Sets abstract response data
setCode()  : mixed
Sets the response code
setContentDisposition()  : mixed
Set the Content-Disposition of the response.
setContentSecurityPolicyDirective()  : mixed
Set a Content-Security-Policy directive for the response.
setContentType()  : mixed
Sets the content type
setExpirationDate()  : mixed
Sets the expiration date for this Response
setHeader()  : mixed
Sets a header For 'Content-Type' or 'Expires' headers please use setContentType() and setExpirationDate()
setMessage()  : mixed
Sets the message Message may be used for user interaction or debugging and is "part" of abstract content
setPage()  : mixed
Sets the current page for this response
setParsedContent()  : void
Sets parsed response data
setParser()  : mixed
Sets the parser This can be an inline function or a class with a method like: string public function(Response $response); Parser needs to return parsed content and set content type
setRequest()  : mixed
Sets the Request object for this Response
setTheme()  : mixed
Sets the current theme
updateContentSecurityPolicy()  : mixed
Update the Content-Security-Policy header of the response based on the set directives set through setContentSecurityPolicyDirective().

Properties

$abstractContent

protected mixed $abstractContent

Abstract response data

$contentSecurityPolicy

protected array<string|int, mixed> $contentSecurityPolicy = array()

Policy-Directives to be set as Content-Security-Policy header. The array has the following structure: [ => [ , ... ], => [ ... ], ... ]

$contentSecurityPolicyReportOnly

protected array<string|int, mixed> $contentSecurityPolicyReportOnly = array()

Policy-Directives to be set as Content-Security-Policy-Report-Only header. The array has the following structure: [ => [ , ... ], => [ ... ], ... ]

$contentType

protected string $contentType = 'text/plain'

Content type

$expirationDate

protected DateTime $expirationDate

Expiration date

$headers

protected array<string|int, mixed> $headers = array()

List of headers (key=>value)

$isParsed

protected bool $isParsed = false

True if the response has parsed content (is reset when parser or abstract content changes)

$parsedContent

protected string $parsedContent = ''

Response data

$parser

protected object|callable $parser

Parser to parse abstract content

Methods

__construct()

Creates a new Response

public __construct(mixed $abstractContent[, int $code = 200 ][, Request $request = null ][, DateTime $expirationDate = null ]) : mixed
Parameters
$abstractContent : mixed
$code : int = 200

(optional) Response code, default is 200

$request : Request = null

(optional) Request object, default is null

$expirationDate : DateTime = null

(optional) Expire date for this response, default is null

getAbstractContent()

Returns the abstract response data

public getAbstractContent() : mixed
Return values
mixed

Abstract response data

getCode()

Returns the response code

public getCode() : int
Return values
int

Response code

getContentDisposition()

Get the Content-Disposition of the response.

public getContentDisposition() : string

Defaults to 'inline' in case non has been set.

Return values
string

Either 'inline' or 'attachment'

getContentSecurityPolicy()

Get the directives of the set Content-Security-Policy of the response.

public getContentSecurityPolicy() : array<string|int, mixed>
Return values
array<string|int, mixed>

The directives and their set values.

getContentType()

Returns the content type

public getContentType() : string
Return values
string

Content type

getExpirationDate()

Returns the expiration date for this Response

public getExpirationDate() : DateTime
Return values
DateTime

Expire date

getHeader()

Returns a header's value

public getHeader(string $key) : string
Parameters
$key : string

Header key

Tags
throws
ResponseException

When trying to get a non-set header

Return values
string

Header value

getHeaders()

Returns a list of headers Please note that this does not include 'Content-Type' and 'Expires' headers

public getHeaders() : array<string|int, mixed>
Return values
array<string|int, mixed>

Key=>value type array

getMessage()

Returns the message Message may be used for user interaction or debugging and is "part" of abstract content

public getMessage() : string
Return values
string

Message

getPage()

Returns the current page for this response

public getPage() : Page
Return values
Page

Page

getParsedContent()

Returns the parsed response data

public getParsedContent() : string
Return values
string

Parsed response data

getParser()

Returns the parser

public getParser() : object|callable
Return values
object|callable

Parser

getRequest()

Returns the Request object for this Response

public getRequest() : Request
Return values
Request

Request this Response is for

parse()

Parses this response

public parse() : mixed
Tags
todo:

Check if casting of parser result is still necessary

send()

Exposes any set HTTP header to the client and returns this response to the client or returns it as string if $finishRequest is set to false.

public send([bool $finishRequest = true ]) : string
Parameters
$finishRequest : bool = true

Defaults to true to end cx execution by returning the parsed content to the client and throwing an InstanceException.

Tags
throws
InstanceException
throws
ResponseException

If content type of response is not set.

Return values
string

Parsed response.

setAbstractContent()

Sets abstract response data

public setAbstractContent(mixed $abstractContent) : mixed
Parameters
$abstractContent : mixed

Abstract response data

setCode()

Sets the response code

public setCode(int $code) : mixed
Parameters
$code : int

Response code

setContentDisposition()

Set the Content-Disposition of the response.

public setContentDisposition(string $disposition) : mixed
Parameters
$disposition : string

Either 'inline' or 'attachment'

setContentSecurityPolicyDirective()

Set a Content-Security-Policy directive for the response.

public setContentSecurityPolicyDirective(string $directive, array<string|int, mixed> $values[, bool $reportOnly = false ]) : mixed
Parameters
$directive : string

The CSP directive to set

$values : array<string|int, mixed>

The values to set the CSP directive to

$reportOnly : bool = false

setContentType()

Sets the content type

public setContentType(string $contentType) : mixed
Parameters
$contentType : string

Content type

setExpirationDate()

Sets the expiration date for this Response

public setExpirationDate(DateTime $expirationDate) : mixed
Parameters
$expirationDate : DateTime

Expiration date (can be set to null)

setHeader()

Sets a header For 'Content-Type' or 'Expires' headers please use setContentType() and setExpirationDate()

public setHeader(string $key, string $value) : mixed
Parameters
$key : string

Header key

$value : string

Header value

Tags
throws
ResponseException

When trying to set 'Content-Type' or 'Expires' header

setMessage()

Sets the message Message may be used for user interaction or debugging and is "part" of abstract content

public setMessage(string $message) : mixed
Parameters
$message : string

Message for user interaction or debugging

setPage()

Sets the current page for this response

public setPage(Page $page) : mixed
Parameters
$page : Page

Page

setParsedContent()

Sets parsed response data

public setParsedContent(string $parsedContent) : void

This should only be used directly for edge-cases. One example would be if we're just forwarding an already parsed response (proxy / internal redirect). All normal requests (frontend, backend, api) should set abstract content and a parser instead!

Parameters
$parsedContent : string

Parsed response data

Tags
todo:

Check if casting $parsedContent is still necessary

setParser()

Sets the parser This can be an inline function or a class with a method like: string public function(Response $response); Parser needs to return parsed content and set content type

public setParser(object|callable $parser) : mixed
Parameters
$parser : object|callable

Parser to parse abstract content

setRequest()

Sets the Request object for this Response

public setRequest(Request $request) : mixed
Parameters
$request : Request

Request this Response is for

updateContentSecurityPolicy()

Update the Content-Security-Policy header of the response based on the set directives set through setContentSecurityPolicyDirective().

protected updateContentSecurityPolicy([bool $reportOnly = false ]) : mixed
Parameters
$reportOnly : bool = false

If set to true, then the Content-Security-Policy-Report-Only header is set instead of the Content-Security-Policy header.


        
On this page

Search results