WebApplicationInterface

Extends ApplicationInterface

Application sub-interface defining a web application class

since

2.0.0

package

Joomla Framework

Methods

allowCache

Set/get cachable state for the response.

allowCache(bool allow = null) : bool

If $allow is set, sets the cachable state of the response. Always returns the current state.

since

2.0.0

Arguments

allow

boolTrue to allow browser caching.

Response

bool

appendBody

Append content to the body content

appendBody(string content) : $this
since

2.0.0

Arguments

content

stringThe content to append to the response body.

Response

$this

clearHeaders

Method to clear any set response headers.

clearHeaders() : $this
since

2.0.0

Response

$this

close

Method to close the application.

close(int code) : void
inherited
since

2.0.0

Arguments

code

intThe exit code (optional; default is 0).

execute

Execute the application.

execute() : void
inherited
since

2.0.0

getBody

Return the body content

getBody() : mixed
since

2.0.0

Response

mixedThe response body as a string.

getHeaders

Method to get the array of response headers to be sent when the response is sent to the client.

getHeaders() : array
since

2.0.0

Response

array

getInput

Method to get the application input object.

getInput() : \Joomla\Input\Input
since

2.0.0

Response

\Joomla\Input\Input

getResponse

Get the PSR-7 Response Object.

getResponse() : \Psr\Http\Message\ResponseInterface
since

2.0.0

Response

\Psr\Http\Message\ResponseInterface

isSslConnection

Determine if we are using a secure (SSL) connection.

isSslConnection() : bool
since

2.0.0

Response

boolTrue if using SSL, false if not.

isValidHttpStatus

Check if the value is a valid HTTP status code

isValidHttpStatus(int code) : bool
since

2.0.0

Arguments

code

intThe potential status code

Response

bool

prependBody

Prepend content to the body content

prependBody(string content) : $this
since

2.0.0

Arguments

content

stringThe content to prepend to the response body.

Response

$this

redirect

Redirect to another URL.

redirect(string url, int|bool status = 303) : void

If the headers have not been sent the redirect will be accomplished using a "301 Moved Permanently" or "303 See Other" code in the header pointing to the new location. If the headers have already been sent this will be accomplished using a JavaScript statement.

since

2.0.0

throws

\InvalidArgumentException

Arguments

url

stringThe URL to redirect to. Can only be http/https URL

status

int|boolThe HTTP status code to be provided. 303 is assumed by default.

sendHeaders

Send the response headers.

sendHeaders() : $this
since

2.0.0

Response

$this

setBody

Set body content. If body content already defined, this will replace it.

setBody(string content) : $this
since

2.0.0

Arguments

content

stringThe content to set as the response body.

Response

$this

setHeader

Method to set a response header.

setHeader(string name, string value, bool replace = false) : $this

If the replace flag is set then all headers with the given name will be replaced by the new one. The headers are stored in an internal array to be sent when the site is sent to the browser.

since

2.0.0

Arguments

name

stringThe name of the header to set.

value

stringThe value of the header to set.

replace

boolTrue to replace any headers with the same name.

Response

$this

setResponse

Set the PSR-7 Response Object.

setResponse(\Psr\Http\Message\ResponseInterface response) : void
since

2.0.0

Arguments

response

\Psr\Http\Message\ResponseInterfaceThe response object