AbstractWebApplication

Extends \Joomla\Application\AbstractApplication

Base class for a Joomla! Web application.

abstract
since

1.0

Methods

__construct

Class constructor.

__construct(\Joomla\Input\Input $input = null, \Joomla\Registry\Registry $config = null) 
inherited
since

1.0

Arguments

$input

\Joomla\Input\InputAn optional argument to provide dependency injection for the application's input object. If the argument is an Input object that object will become the application's input object, otherwise a default input object is created.

$config

\Joomla\Registry\RegistryAn optional argument to provide dependency injection for the application's config object. If the argument is a Registry object that object will become the application's config object, otherwise a default config object is created.

allowCache

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

allowCache(boolean $allow = null) : boolean
since

1.0

Arguments

$allow

booleanTrue to allow browser caching.

Response

boolean

appendBody

Append content to the body content

appendBody(string $content) : \Joomla\Application\AbstractWebApplication
since

1.0

Arguments

$content

stringThe content to append to the response body.

Response

\Joomla\Application\AbstractWebApplicationInstance of $this to allow chaining.

checkConnectionAlive

Method to check the current client connection status to ensure that it is alive. We are wrapping this to isolate the connection_status() function from our code base for testing reasons.

checkConnectionAlive() : boolean
see \Joomla\Application\connection_status()
since

1.0

Response

booleanTrue if the connection is valid and normal.

checkHeadersSent

Method to check to see if headers have already been sent. We are wrapping this to isolate the headers_sent() function from our code base for testing reasons.

checkHeadersSent() : boolean
see \Joomla\Application\headers_sent()
since

1.0

Response

booleanTrue if the headers have already been sent.

checkToken

Checks for a form token in the request.

checkToken(string $method = 'post') : boolean

Use in conjunction with getFormToken.

since

1.0

Arguments

$method

stringThe request method in which to look for the token key.

Response

booleanTrue if found and valid, false otherwise.

clearHeaders

Method to clear any set response headers.

clearHeaders() : \Joomla\Application\AbstractWebApplication
since

1.0

Response

\Joomla\Application\AbstractWebApplicationInstance of $this to allow chaining.

close

Method to close the application.

close(integer $code) : void
inherited
since

1.0

Arguments

$code

integerThe exit code (optional; default is 0).

compress

Checks the accept encoding of the browser and compresses the data before sending it to the client if possible.

compress() : void
since

1.0

detectRequestUri

Method to detect the requested URI from server environment variables.

detectRequestUri() : string
since

1.0

Response

stringThe requested URI

doExecute

Method to run the application routines. Most likely you will want to instantiate a controller and execute it, or perform some sort of task directly.

doExecute() : void
inherited abstract
since

1.0

execute

Execute the application.

execute() : void
inherited
since

1.0

get

Returns a property of the object or the default value if the property is not set.

get(string $key, mixed $default = null) : mixed
inherited
since

1.0

Arguments

$key

stringThe name of the property.

$default

mixedThe default value (optional) if none is set.

Response

mixedThe value of the configuration.

getBody

Return the body content

getBody(boolean $asArray = false) : mixed
since

1.0

Arguments

$asArray

booleanTrue to return the body as an array of strings.

Response

mixedThe response body either as an array or concatenated string.

getFormToken

Method to determine a hash for anti-spoofing variable names

getFormToken(boolean $forceNew = false) : string
since

1.0

Arguments

$forceNew

booleanIf true, force a new token to be created

Response

stringHashed var name

getHeaders

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

getHeaders() : array
since

1.0

Response

array

getHttpStatusValue

Check if a given value can be successfully mapped to a valid http status value

getHttpStatusValue(string|integer $value) : string
since

1.8.0

Arguments

$value

string|integerThe given status as int or string

Response

string

getLogger

Get the logger.

getLogger() : \Psr\Log\LoggerInterface
inherited
since

1.0

Response

\Psr\Log\LoggerInterface

getSession

Method to get the application session object.

getSession() : \Joomla\Session\Session
since

1.0

Response

\Joomla\Session\SessionThe session object

header

Method to send a header to the client. We are wrapping this to isolate the header() function from our code base for testing reasons.

header(string $string, boolean $replace = true, integer $code = null) : void
see \Joomla\Application\AbstractWebApplication::header()
since

1.0

Arguments

$string

stringThe header string.

$replace

booleanThe optional replace parameter indicates whether the header should replace a previous similar header, or add a second header of the same type.

$code

integerForces the HTTP response code to the specified value. Note that this parameter only has an effect if the string is not empty.

initialise

Custom initialisation method.

initialise() : void
inherited

Called at the end of the AbstractApplication::__construct method. This is for developers to inject initialisation code for their application classes.

since

1.0

isAscii

Tests whether a string contains only 7bit ASCII bytes.

isAscii(string $str) : boolean
static

You might use this to conditionally check whether a string needs handling as UTF-8 or not, potentially offering performance benefits by using the native PHP equivalent if it's just ASCII e.g.;

since

1.4.0

Arguments

$str

stringThe string to test.

Response

booleanTrue if the string is all ASCII

isRedirectState

Checks if a state is a redirect state

isRedirectState(integer $state) : boolean
since

1.8.0

Arguments

$state

integerThe HTTP status code.

Response

boolean

isSslConnection

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

isSslConnection() : boolean
since

1.0

Response

booleanTrue if using SSL, false if not.

isValidHttpStatus

Check if the value is a valid HTTP status code

isValidHttpStatus(integer $code) : boolean
since

1.8.1

Arguments

$code

integerThe potential status code

Response

boolean

loadSystemUris

Method to load the system URI strings for the application.

loadSystemUris(string $requestUri = null) : void
since

1.0

Arguments

$requestUri

stringAn optional request URI to use instead of detecting one from the server environment variables.

prependBody

Prepend content to the body content

prependBody(string $content) : \Joomla\Application\AbstractWebApplication
since

1.0

Arguments

$content

stringThe content to prepend to the response body.

Response

\Joomla\Application\AbstractWebApplicationInstance of $this to allow chaining.

redirect

Redirect to another URL.

redirect(string $url, integer $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

1.0

throws

\InvalidArgumentException

Arguments

$url

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

$status

integerThe HTTP status code to be provided. 303 is assumed by default.

respond

Method to send the application response to the client. All headers will be sent prior to the main application output data.

respond() : void
since

1.0

sendHeaders

Send the response headers.

sendHeaders() : \Joomla\Application\AbstractWebApplication
since

1.0

Response

\Joomla\Application\AbstractWebApplicationInstance of $this to allow chaining.

set

Modifies a property of the object, creating it if it does not already exist.

set(string $key, mixed $value = null) : mixed
inherited
since

1.0

Arguments

$key

stringThe name of the property.

$value

mixedThe value of the property to set (optional).

Response

mixedPrevious value of the property

setBody

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

setBody(string $content) : \Joomla\Application\AbstractWebApplication
since

1.0

Arguments

$content

stringThe content to set as the response body.

Response

\Joomla\Application\AbstractWebApplicationInstance of $this to allow chaining.

setConfiguration

Sets the configuration for the application.

setConfiguration(\Joomla\Registry\Registry $config) : \Joomla\Application\AbstractApplication
inherited
since

1.0

Arguments

$config

\Joomla\Registry\RegistryA registry object holding the configuration.

Response

\Joomla\Application\AbstractApplicationReturns itself to support chaining.

setHeader

Method to set a response header. 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.

setHeader(string $name, string $value, boolean $replace = false) : \Joomla\Application\AbstractWebApplication
since

1.0

Arguments

$name

stringThe name of the header to set.

$value

stringThe value of the header to set.

$replace

booleanTrue to replace any headers with the same name.

Response

\Joomla\Application\AbstractWebApplicationInstance of $this to allow chaining.

setLogger

Set the logger.

setLogger(\Psr\Log\LoggerInterface $logger) : \Joomla\Application\AbstractApplication
inherited
since

1.0

Arguments

$logger

\Psr\Log\LoggerInterfaceThe logger.

Response

\Joomla\Application\AbstractApplicationReturns itself to support chaining.

setSession

Sets the session for the application to use, if required.

setSession(\Joomla\Session\Session $session) : \Joomla\Application\AbstractWebApplication
since

1.0

Arguments

$session

\Joomla\Session\SessionA session object.

Response

\Joomla\Application\AbstractWebApplicationReturns itself to support chaining.

Properties

charSet

Character encoding string.

since

1.0

Type(s)

string

mimeType

Response mime type.

since

1.0

Type(s)

string

httpVersion

HTTP protocol version.

since

1.9.0

Type(s)

string

modifiedDate

The body modified date for response headers.

since

1.0

Type(s)

\DateTime

client

The application client object.

response

The application response object.

since

1.0

Type(s)

object

session

The application session object.

since

1.0

Type(s)

\Joomla\Session\Session

responseMap

A map of integer HTTP response codes to the full HTTP Status for the headers.

config

The application configuration object.

inherited
since

1.0

Type(s)

\Joomla\Registry\Registry

input

The application input object.

inherited
since

1.0

Type(s)

\Joomla\Input\Input

logger

A logger.

inherited
since

1.0

Type(s)

\Psr\Log\LoggerInterface